You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(233) |
Sep
(199) |
Oct
(206) |
Nov
(185) |
Dec
(270) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(232) |
Feb
(426) |
Mar
(623) |
Apr
(592) |
May
(506) |
Jun
(389) |
Jul
(160) |
Aug
(3) |
Sep
(1) |
Oct
(1) |
Nov
(2) |
Dec
(5) |
2007 |
Jan
(1) |
Feb
(1) |
Mar
(2) |
Apr
(2) |
May
(4) |
Jun
(2) |
Jul
|
Aug
(3) |
Sep
(5) |
Oct
(9) |
Nov
(6) |
Dec
(6) |
2008 |
Jan
(3) |
Feb
|
Mar
(1) |
Apr
(3) |
May
(3) |
Jun
(5) |
Jul
(10) |
Aug
(2) |
Sep
(12) |
Oct
(10) |
Nov
(54) |
Dec
(49) |
2009 |
Jan
(19) |
Feb
(13) |
Mar
(20) |
Apr
(24) |
May
(44) |
Jun
(29) |
Jul
(32) |
Aug
(10) |
Sep
(7) |
Oct
(10) |
Nov
(4) |
Dec
(17) |
2010 |
Jan
(14) |
Feb
(5) |
Mar
(23) |
Apr
(50) |
May
(31) |
Jun
(9) |
Jul
(5) |
Aug
(4) |
Sep
(7) |
Oct
(5) |
Nov
(2) |
Dec
(3) |
2011 |
Jan
(12) |
Feb
(5) |
Mar
(5) |
Apr
(3) |
May
(4) |
Jun
(3) |
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
2012 |
Jan
(1) |
Feb
(2) |
Mar
|
Apr
(1) |
May
(1) |
Jun
(2) |
Jul
(4) |
Aug
(1) |
Sep
|
Oct
(1) |
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
(1) |
2015 |
Jan
|
Feb
|
Mar
(2) |
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <jbo...@li...> - 2006-05-15 14:05:14
|
Author: soh...@jb... Date: 2006-05-15 10:05:04 -0400 (Mon, 15 May 2006) New Revision: 4229 Added: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/PageNavigator.java Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/Constants.java labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/ForumsJSFPortlet.java labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/JSFUtil.java labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/PortalUtil.java labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/ThemeHelper.java labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewCategory.java labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewForum.java labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/classes/ResourceJSF.properties labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums.taglib.xml labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/portlet.xml labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/forums/viewforum_body.xhtml Log: http://jira.jboss.com/jira/browse/JBFORUMS-73 - Display a Forum and its topics http://jira.jboss.com/jira/browse/JBFORUMS-88 - A Generic PageNavigator Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/Constants.java =================================================================== --- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/Constants.java 2006-05-15 12:29:34 UTC (rev 4228) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/Constants.java 2006-05-15 14:05:04 UTC (rev 4229) @@ -48,6 +48,7 @@ public static final String p_attachment = "ATTACHMENT"; public static final String p_vote = "vote"; public static final String p_results = "results"; + public static final String p_page = "page"; //other constants------------------------------------------------------------------------------------------------------------------------------- public static final String QUOTE = "quote"; @@ -80,5 +81,26 @@ /** * DOCUMENT_ME */ - public static final int TOPIC_LOCKED = 1; + public static final int TOPIC_LOCKED = 1; + + + /** + * DOCUMENT_ME + */ + int POST_NORMAL = 0; + + /** + * DOCUMENT_ME + */ + int POST_STICKY = 1; + + /** + * DOCUMENT_ME + */ + int POST_ANNOUNCE = 2; + + /** + * DOCUMENT_ME + */ + int POST_GLOBAL_ANNONCE = 3; } Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/ForumsJSFPortlet.java =================================================================== --- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/ForumsJSFPortlet.java 2006-05-15 12:29:34 UTC (rev 4228) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/ForumsJSFPortlet.java 2006-05-15 14:05:04 UTC (rev 4229) @@ -22,11 +22,16 @@ package org.jboss.portlet.forums.ui; import org.apache.myfaces.portlet.MyFacesGenericPortlet; +import org.jboss.portlet.JBossRenderRequest; +import org.jboss.portlet.JBossRenderResponse; import java.io.IOException; +//portlet api import javax.portlet.ActionRequest; import javax.portlet.ActionResponse; +import javax.portlet.RenderRequest; +import javax.portlet.RenderResponse; import javax.portlet.PortletException; /** @@ -40,11 +45,11 @@ * Called by the portlet container to allow the portlet to process an action request. */ public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException - { + { this.setupRenderParameters(request,response); super.processAction(request,response); } - + /** * Not sure why this needs to be done... * This method tends to propagate the request parameters over to the JSF layer @@ -65,6 +70,7 @@ String userId = ForumUtil.getParameter(request,Constants.p_userId); String vote = ForumUtil.getParameter(request,Constants.p_vote); String results = ForumUtil.getParameter(request,Constants.p_results); + String page = ForumUtil.getParameter(request,Constants.p_page); if(categoryId!=null && categoryId.trim().length()>0) { response.setRenderParameter(Constants.p_categoryId,categoryId); @@ -109,5 +115,9 @@ { response.setRenderParameter(Constants.p_results,results); } + if(page!=null && page.trim().length()>0) + { + response.setRenderParameter(Constants.p_page,page); + } } } Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/JSFUtil.java =================================================================== --- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/JSFUtil.java 2006-05-15 12:29:34 UTC (rev 4228) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/JSFUtil.java 2006-05-15 14:05:04 UTC (rev 4229) @@ -48,8 +48,6 @@ * * @author sshah * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates */ public static String getRequestParameter(String name) { @@ -138,8 +136,6 @@ * * @author sshah * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates */ public static String handleException(Exception e) { Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/PortalUtil.java =================================================================== --- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/PortalUtil.java 2006-05-15 12:29:34 UTC (rev 4228) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/PortalUtil.java 2006-05-15 14:05:04 UTC (rev 4229) @@ -137,8 +137,7 @@ { String preference = null; - Object o = - FacesContext.getCurrentInstance().getExternalContext().getRequest(); + Object o = FacesContext.getCurrentInstance().getExternalContext().getRequest(); if (!JSFUtil.isAnonymous() && o instanceof PortletRequest) { PortletRequest request = (PortletRequest) o; Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/ThemeHelper.java =================================================================== --- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/ThemeHelper.java 2006-05-15 12:29:34 UTC (rev 4228) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/ThemeHelper.java 2006-05-15 14:05:04 UTC (rev 4229) @@ -25,9 +25,12 @@ import org.jboss.portlet.forums.ForumsConstants; import org.jboss.portlet.forums.properties.TCCLXProperties; +import org.jboss.portlet.forums.theme.FolderType; import org.jboss.portlet.forums.theme.ForumsTheme; +import org.jboss.portlet.forums.model.Topic; + /** * @author <a href="mailto:soh...@jb...">Sohil Shah</a> * @@ -74,6 +77,11 @@ return ThemeHelper.singleton; } + //method linked to facelet functions--------------------------------------------------------------------------------------------------------- + /** + * + * + */ public static String getURL(String urlKey) { ThemeHelper helper = null; @@ -99,6 +107,31 @@ /** * + * + */ + public static String getFolderTypeURL(Topic topic,boolean isAnonymous) + { + String folderTypeURL = ThemeHelper.getURL("resourceFolderURL"); + + int hotThreshold = 10; + FolderType folderType = ThemeHelper.singleton.theme.getFolderType(topic.getType(), + topic.getStatus(), topic.getReplies() >= hotThreshold); + + if(!isAnonymous) + { + folderTypeURL = folderType.folderNew; + } + else + { + folderTypeURL = folderType.folder; + } + + return folderTypeURL; + } + //-------------------------------------------------------------------------------------------------------------------------------------------- + + /** + * * @return */ public String getResourceForumURL() @@ -113,5 +146,5 @@ public String getResourceForumLockedURL() { return this.theme.resourceForumLockedURL; - } + } } Added: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/PageNavigator.java =================================================================== --- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/PageNavigator.java 2006-05-15 12:29:34 UTC (rev 4228) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/PageNavigator.java 2006-05-15 14:05:04 UTC (rev 4229) @@ -0,0 +1,189 @@ +/* +* 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.portlet.forums.ui.view; + +import java.util.Collection; +import java.util.ArrayList; + +/* + * Created on May 11, 2006 + * + * @author <a href="mailto:soh...@jb...">Sohil Shah</a> + */ +public class PageNavigator +{ + /** + * + */ + private int totalPages = 0; + private int pageSize = 0; + private int currentPage = 0; + private Object[] entries = null; + + /** + * + * + */ + public PageNavigator(Object[] entries,int pageSize,int currentPage) + { + if(entries==null) + { + throw new IllegalStateException("PageNavigator cannot be initialized with a null set of entries"); + } + + this.pageSize = pageSize; + this.currentPage = currentPage; + int totalEntries = 0; + if(entries!=null) + { + this.entries = entries; + totalEntries = this.entries.length; + } + + + //calculate the totalNumberofPages that will be made + double totalDbl = totalEntries; + double pageSizeDbl = this.pageSize; + double pageCountDbl = totalDbl/pageSizeDbl; + this.totalPages = (int)Math.ceil(pageCountDbl); + } + + /** + * + * + */ + public int getTotalPages() + { + return this.totalPages; + } + + /** + * + * + */ + public int getCurrentPage() + { + return this.currentPage; + } + + + /** + * + * + */ + public int getBeginIndex() + { + int beginIndex = 0; + + beginIndex = this.currentPage * this.pageSize; + + return beginIndex; + } + + /** + * + * + */ + public int getEndIndex() + { + int endIndex = 0; + + endIndex = this.getBeginIndex() + this.pageSize; + int totalEntries = 0; + if(this.entries!=null) + { + totalEntries = this.entries.length; + } + if(endIndex >= totalEntries) + { + endIndex = totalEntries; + } + + return endIndex; + } + + /** + * + * + */ + public Collection getPage() + { + Collection page = new ArrayList(); + + int beginIndex = this.getBeginIndex(); + int endIndex = this.getEndIndex(); + int totalEntries = 0; + if(this.entries!=null) + { + totalEntries = this.entries.length; + } + + //reset the page navigation if the start cursor is outside the range (both forward and backward) + if(beginIndex >= totalEntries || beginIndex < 0) + { + this.setCurrentPage(0); //go to the first page + beginIndex = this.getBeginIndex(); + endIndex = this.getEndIndex(); + } + + //get the entries for this page + for(int i=beginIndex;i<endIndex;i++) + { + page.add(this.entries[i]); + } + + return page; + } + + + /** + * + * + */ + public String getPageNumber() + { + return String.valueOf(this.getCurrentPage()+1); + } + + /** + * + * + */ + public int[] getPages() + { + int[] pages = new int[this.getTotalPages()]; + for(int i=0;i<pages.length;i++) + { + pages[i] = i+1; + } + return pages; + } + + /** + * + * + */ + public void setCurrentPage(int currentPage) + { + this.currentPage = currentPage; + } +} Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewCategory.java =================================================================== --- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewCategory.java 2006-05-15 12:29:34 UTC (rev 4228) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewCategory.java 2006-05-15 14:05:04 UTC (rev 4229) @@ -113,9 +113,6 @@ /** * * @author sshah - * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates */ public ViewCategory() { Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewForum.java =================================================================== --- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewForum.java 2006-05-15 12:29:34 UTC (rev 4228) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewForum.java 2006-05-15 14:05:04 UTC (rev 4229) @@ -21,11 +21,18 @@ */ package org.jboss.portlet.forums.ui.view; +import java.util.Collection; +import java.util.Iterator; +import java.util.ArrayList; +import java.util.List; + import org.jboss.portlet.forums.model.Forum; +import org.jboss.portlet.forums.model.Topic; import org.jboss.portlet.forums.ui.Constants; import org.jboss.portlet.forums.ui.BaseController; import org.jboss.portlet.forums.ui.JSFUtil; import org.jboss.portlet.forums.ui.ForumUtil; +import org.jboss.portlet.forums.ui.PortalUtil; //jsf imports @@ -35,36 +42,184 @@ * */ public class ViewForum extends BaseController -{ +{ + //preference related data + private int topicsPerForum = 0; //feed in the topicsPerForum value as a managed property + private String topicsPerForumKey = null; //feed in the topicsPerForum preference key as managed property + //business data being generated in this bean by executing ui actions //this is data is created such that it can be consumed by the view components //like facelets private Forum forum = null; - + private PageNavigator pageNavigator = null; + private Collection page = new ArrayList(); + //----------------bean configuration supplied by the forums-config.xml--------------------------------------------------------------------------------------------- - - + /** + * @return Returns the topicsPerForum. + */ + public int getTopicsPerForum() + { + return topicsPerForum; + } + /** + * @param topicsPerForum The topicsPerForum to set. + */ + public void setTopicsPerForum(int topicsPerForum) + { + this.topicsPerForum = topicsPerForum; + } + + /** + * @return Returns the topicsPerForumKey. + */ + public String getTopicsPerForumKey() + { + return topicsPerForumKey; + } + /** + * @param topicsPerForumKey The topicsPerForumKey to set. + */ + public void setTopicsPerForumKey(String topicsPerForumKey) + { + this.topicsPerForumKey = topicsPerForumKey; + } //----------------business data being generated for use by the view components like facelets--------------------------------------------------------------------------------------- + /** + * + */ public Forum getForum() { return this.forum; - } - public String getPagination() + } + + //page navigation related methods on this bean-------------------------------------------------------------------------------------------- + /** + * + */ + public PageNavigator getPageNavigator() { - /** - * TODO: implement real code to get the pagination... - */ - //stub code - return "10"; + return this.pageNavigator; } - public String getPageNumber() + //-------------------------------------------------------------------------------------------- + /** + * + * + */ + public Collection getAnnouncements() { - /** - * TODO: implement real code to get the pageNumber... - */ - //stub code - return "2"; + Collection announcements = new ArrayList(); + Collection topics = this.forum.getTopics(); + if(topics!=null) + { + for(Iterator itr=topics.iterator();itr.hasNext();) + { + Topic cour = (Topic)itr.next(); + if(cour.getType()==Constants.POST_ANNOUNCE) + { + announcements.add(cour); + } + } + } + return announcements; } + + /** + * + * + */ + public boolean isAnnouncementsPresent() + { + boolean present = false; + Collection topics = this.forum.getTopics(); + if(topics!=null) + { + for(Iterator itr=topics.iterator();itr.hasNext();) + { + Topic cour = (Topic)itr.next(); + if(cour.getType()==Constants.POST_ANNOUNCE) + { + present = true; + break; + } + } + } + return present; + } + + /** + * + * + */ + public Collection getStickyThreads() + { + Collection stickyThreads = new ArrayList(); + for(Iterator itr=this.page.iterator();itr.hasNext();) + { + Topic cour = (Topic)itr.next(); + if(cour.getType()==Constants.POST_STICKY) + { + stickyThreads.add(cour); + } + } + return stickyThreads; + } + + /** + * + * + */ + public boolean isStickyThreadsPresent() + { + boolean present = false; + for(Iterator itr=this.page.iterator();itr.hasNext();) + { + Topic cour = (Topic)itr.next(); + if(cour.getType()==Constants.POST_STICKY) + { + present = true; + break; + } + } + return present; + } + + /** + * + * + */ + public Collection getNormalThreads() + { + Collection normalThreads = new ArrayList(); + for(Iterator itr=this.page.iterator();itr.hasNext();) + { + Topic cour = (Topic)itr.next(); + if(cour.getType()==Constants.POST_NORMAL) + { + normalThreads.add(cour); + } + } + return normalThreads; + } + + /** + * + * + */ + public boolean isNormalThreadsPresent() + { + boolean present = false; + for(Iterator itr=this.page.iterator();itr.hasNext();) + { + Topic cour = (Topic)itr.next(); + if(cour.getType()==Constants.POST_NORMAL) + { + present = true; + break; + } + } + return present; + } //------------user preferences------------------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------------------------------------------- @@ -74,31 +229,97 @@ */ public ViewForum() { - super(); - try - { - this.execute(); - } - catch(Exception e) - { - JSFUtil.handleException(e); - } + super(); } //ui actions supported by this bean---------------------------------------------------------------------------------------------------- + /** + * + */ + public boolean isInitialized() + { + boolean initialized = false; + try + { + this.execute(); + initialized = true; + } + catch(Exception e) + { + JSFUtil.handleException(e); + } + return initialized; + } + + /** + * + * + */ private void execute() throws Exception { + //parse the input parameters + String page = ForumUtil.getParameter(Constants.p_page); int forumId = -1; String f = ForumUtil.getParameter(Constants.p_forumId); if(f!=null && f.trim().length()>0) { forumId = Integer.parseInt(f); - } + } + + //grab the data to be displayed for this page if(forumId!=-1) { - // start with a stub implementation + //setup the business objects like the forum, topics etc that will be displayed this.forum = BaseController.getForumsModule().findForumById(new Integer(forumId)); - } + List allTopics = this.forum.getTopics(); + Object[] topicObjects = null; + if(allTopics!=null) + { + //filter out any announcements from this array....Announcements appear on all pages regardless + Collection topics = new ArrayList(); + for(Iterator itr=allTopics.iterator();itr.hasNext();) + { + Topic cour = (Topic)itr.next(); + if(cour.getType()!=Constants.POST_ANNOUNCE) + { + topics.add(cour); + } + } + topicObjects = topics.toArray(); + } + + + //calculate the pageSize of this forum listing of topics + int pageSize = this.topicsPerForum; //default page size + + //get the user's preferred pageSize for viewing a forum and its list of topics, + //instead of using the default page size + String topicsPerForum = PortalUtil.getPreference(this.topicsPerForumKey); + if(topicsPerForum!=null && topicsPerForum.trim().length()>0) + { + int cour = 0; + try{cour = Integer.parseInt(topicsPerForum);}catch(NumberFormatException nfe){} + if(cour>0) + { + pageSize = cour; //here override the default page size with the user's preference + } + } + + //setup the pageNavigator for this forum + this.pageNavigator = new PageNavigator( + topicObjects, //total number of entries to be split up into pages + pageSize, + 0 //currently selected page being displayed, first page by default + ); + + if(page!=null && page.trim().length()>0) + { + //setup the page data + this.pageNavigator.setCurrentPage(Integer.parseInt(page)); + } + + this.page = this.pageNavigator.getPage(); + } } //------------------------------------------------------------------------------------------------------------------------------------- } Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/classes/ResourceJSF.properties =================================================================== --- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/classes/ResourceJSF.properties 2006-05-15 12:29:34 UTC (rev 4228) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/classes/ResourceJSF.properties 2006-05-15 14:05:04 UTC (rev 4229) @@ -366,7 +366,7 @@ Rules_moderate_1=You <b>cannot</b> Rules_moderate_2=moderate this forum -No_topics_post_one=There are no posts in this forum.<br />Click on the <b>Post New Topic</b> link on this page to post one. +No_topics_post_one=There are no posts in this forum.<br/><br/>Click on the <b>New Topic</b> link on this page to post one. # Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml =================================================================== --- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml 2006-05-15 12:29:34 UTC (rev 4228) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml 2006-05-15 14:05:04 UTC (rev 4229) @@ -9,11 +9,11 @@ <!-- general application configuration --> <application> <!-- jbossportal-facelets integration --> - <!--property-resolver>org.jboss.portal.faces.el.DelegatingPropertyResolver</property-resolver> - <view-handler>com.sun.facelets.FaceletPortletViewHandler</view-handler--> + <property-resolver>org.jboss.portal.faces.el.DelegatingPropertyResolver</property-resolver> + <view-handler>com.sun.facelets.FaceletPortletViewHandler</view-handler> <!-- standalone facelets integration --> - <view-handler>com.sun.facelets.FaceletViewHandler</view-handler> + <!--view-handler>com.sun.facelets.FaceletViewHandler</view-handler--> <!-- internationalization --> <locale-config> @@ -107,7 +107,16 @@ <managed-bean> <managed-bean-name>forum</managed-bean-name> <managed-bean-class>org.jboss.portlet.forums.ui.view.ViewForum</managed-bean-class> - <managed-bean-scope>request</managed-bean-scope> + <managed-bean-scope>request</managed-bean-scope> + <!-- user preferences related configuration --> + <managed-property> + <property-name>topicsPerForumKey</property-name> + <value>topicsperforum</value> + </managed-property> + <managed-property> + <property-name>topicsPerForum</property-name> + <value>10</value> + </managed-property> </managed-bean> <navigation-rule> <from-view-id>/views/forums/viewforum_body.xhtml</from-view-id> Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums.taglib.xml =================================================================== --- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums.taglib.xml 2006-05-15 12:29:34 UTC (rev 4228) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums.taglib.xml 2006-05-15 14:05:04 UTC (rev 4229) @@ -26,16 +26,8 @@ <function-name>constantInt</function-name> <function-class>org.jboss.portlet.forums.ui.ConstantsHelper</function-class> <function-signature>int getConstantInt(java.lang.String)</function-signature> - </function> + </function> <!-- - function to get theme URL location - --> - <function> - <function-name>themeURL</function-name> - <function-class>org.jboss.portlet.forums.ui.ThemeHelper</function-class> - <function-signature>java.lang.String getURL(java.lang.String)</function-signature> - </function> - <!-- function generates the contextPath of the application --> <function> @@ -78,5 +70,21 @@ <function-name>votePercent</function-name> <function-class>org.jboss.portlet.forums.ui.PortalUtil</function-class> <function-signature>float getVotePercent(org.jboss.portlet.forums.model.Poll,org.jboss.portlet.forums.model.PollOption)</function-signature> - </function> + </function> + <!-- + function to get theme URL location + --> + <function> + <function-name>themeURL</function-name> + <function-class>org.jboss.portlet.forums.ui.ThemeHelper</function-class> + <function-signature>java.lang.String getURL(java.lang.String)</function-signature> + </function> + <!-- + function to get folderTypeURL + --> + <function> + <function-name>folderTypeURL</function-name> + <function-class>org.jboss.portlet.forums.ui.ThemeHelper</function-class> + <function-signature>java.lang.String getFolderTypeURL(org.jboss.portlet.forums.model.Topic,boolean)</function-signature> + </function> </facelet-taglib> \ No newline at end of file Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/portlet.xml =================================================================== --- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/portlet.xml 2006-05-15 12:29:34 UTC (rev 4228) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/portlet.xml 2006-05-15 14:05:04 UTC (rev 4229) @@ -101,5 +101,51 @@ <portlet-info> <title>JSF Forums</title> </portlet-info> + <portlet-preferences> + <preference> + <name>summarymode</name> + <value>0</value> + </preference> + <preference> + <name>summarytopiclimit</name> + <value>6</value> + </preference> + <preference> + <name>summarytopicdays</name> + <value>20</value> + </preference> + <preference> + <name>summarytopicreplies</name> + <value>15</value> + </preference> + <preference> + <name>topicsperforum</name> + <value>10</value> + </preference> + <!-- not yet integrated with the JSF layer --> + <preference> + <name>notifyreply</name> + <value>1</value> + </preference> + <preference> + <name>allowhtml</name> + <value>1</value> + <!-- + <read-only>true</read-only> + --> + </preference> + <preference> + <name>postorder</name> + <value>ascending</value> + </preference> + <preference> + <name>postspertopic</name> + <value>15</value> + </preference> + <preference> + <name>dateformat</name> + <value>EEE MMM d, yyyy HH:mm aaa</value> + </preference> + </portlet-preferences> </portlet> </portlet-app> Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/forums/viewforum_body.xhtml =================================================================== --- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/forums/viewforum_body.xhtml 2006-05-15 12:29:34 UTC (rev 4228) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/forums/viewforum_body.xhtml 2006-05-15 14:05:04 UTC (rev 4229) @@ -33,7 +33,11 @@ <ui:composition template="/views/common/common.xhtml"> <ui:define name="mainContent"> -<c:if test="#{forum.forum!=null && forum.forum.id!=-1}"> + +<c:if test="#{forum.initialized && forum.forum!=null && forum.forum.id!=-1}"> + + + <!-- title, newtopic, forum, and page navigation --> <table width="100%" cellspacing="2" cellpadding="2" border="0" align="center"> <tr> <td align="left" valign="bottom" colspan="2"> @@ -41,10 +45,7 @@ <f:param name="f" value="#{forum.forum.id}"/> <h:outputText value="#{forum.forum.name}"/> </h:outputLink> - </td> - <td align="right" valign="bottom" nowrap="nowrap"> - <span class="gensmall"><b>#{forum.pagination}</b></span> - </td> + </td> </tr> <tr> <td align="left" valign="middle" width="50" colspan="2"> @@ -86,10 +87,58 @@ <h:outputText value="#{forum.forum.name}"/> </h:outputLink> </span> - </td> + </td> + <!-- page navigation --> + <c:if test="#{forum.pageNavigator.totalPages gt 1}"> + <td align="right" valign="middle" nowrap="nowrap"> + <span class="gensmall"></span><br/> + <span class="nav"> + Goto page + <!-- previous link --> + <c:if test="#{forum.pageNavigator.pageNumber gt 1}"> + &nbsp;&nbsp; + <h:outputLink value="#{forums:outputLink(shared.links['forum'],true)}"> + <f:param name="f" value="#{forum.forum.id}"/> + <f:param name="page" value="#{forum.pageNavigator.currentPage-1}"/> + <h:outputText value="Previous"/> + </h:outputLink> + &nbsp;&nbsp; + </c:if> + <!-- actual pages --> + <c:forEach items="#{forum.pageNavigator.pages}" var="page" varStatus="idx"> + <c:choose> + <c:when test="#{forum.pageNavigator.pageNumber==page}"> + <b>${page}</b> + </c:when> + <c:otherwise> + <h:outputLink value="#{forums:outputLink(shared.links['forum'],true)}"> + <f:param name="f" value="#{forum.forum.id}"/> + <f:param name="page" value="#{page-1}"/> + <h:outputText value="${page}"/> + </h:outputLink> + </c:otherwise> + </c:choose> + <c:if test="${idx.index-1 ne forum.pageNavigator.totalPages-1}"> + <f:verbatim>,</f:verbatim> + </c:if> + </c:forEach> + <!-- Next link --> + <c:if test="#{forum.pageNavigator.pageNumber lt forum.pageNavigator.totalPages}"> + &nbsp;&nbsp; + <h:outputLink value="#{forums:outputLink(shared.links['forum'],true)}"> + <f:param name="f" value="#{forum.forum.id}"/> + <f:param name="page" value="#{forum.pageNavigator.currentPage+1}"/> + <h:outputText value="Next"/> + </h:outputLink> + &nbsp;&nbsp; + </c:if> + </span> + </td> + </c:if> </tr> </table> + <!-- display the list of topics associated with this forum --> <table border="0" cellpadding="4" cellspacing="1" width="100%" class="forumline"> <tr> @@ -101,115 +150,268 @@ <th width="50" align="center" class="thTop" nowrap="nowrap">&nbsp;${resource.Views}&nbsp;</th> <th align="center" class="thCornerR" nowrap="nowrap">&nbsp;${resource.Last_Post}&nbsp;</th> </tr> - <!-- TODO: display the list of topics for this forum --> - <c:forEach items="#{forum.forum.topics}" var="topicrow"> - <tr> - <td class="row1" align="center" valign="middle" width="20"> - <img src="#{forums:themeURL('resourceFolderURL')}" width="19" height="18" - alt="${resource.Topic_Moved}" - title="${resource.Topic_Moved}"/> - </td> - <td class="row1" width="100%"> - <span class="topictitle"> - <a href="link to last post"> - <img border="0" src="#{forums:themeURL('resourceIconLatestReplyURL')}"/></a> - <!-- hookup-TOPIC_TYPE --> - <h:outputLink value="#{forums:outputLink(shared.links['topic'],true)}" styleClass="topictitle"> - <f:param name="t" value="${topicrow.id}"/> - <h:outputText value="${topicrow.subject}"/> - </h:outputLink> - </span> - <span class="gensmall"> - <br/> - ${resource.Goto_page} - </span> - </td> - <td class="row2" align="center" valign="middle"> - <span class="postdetails"> - ${topicrow.replies} - </span> - </td> - <td class="row3" align="center" valign="middle"> - <span class="name"> - ${topicrow.firstPost.poster.user.userName} - </span> - </td> - <td class="row2" align="center" valign="middle"> - <span class="postdetails"> - ${topicrow.viewCount} - </span> - </td> - <td class="row3Right" align="center" valign="middle" nowrap="nowrap"> - <span class="postdetails"> - ${topicrow.lastPostDate} - <br/> - ${topicrow.lastPost.poster.user.userName} - <!-- TODO: LINK TO LAST POST NEEDED --> - <a href="link to lastPost"><img border="0" src="#{forums:themeURL('resourceIconLatestReplyURL')}"/></a> - </span> - </td> - </tr> - </c:forEach> - <!--n:iterate ctx="topicrow"> - <tr> - <td class="row1" align="center" valign="middle" width="20"> - <img src="${n:out("topicrow.TOPIC_FOLDER_IMG")}" width="19" height="18" - alt="${n:out("topicrow.L_TOPIC_FOLDER_ALT")}" - title="${n:out("topicrow.L_TOPIC_FOLDER_ALT")}"/> - </td> - <td class="row1" width="100%"> - <span class="topictitle"> - ${n:out("topicrow.NEWEST_POST_IMG")}${n:out("topicrow.TOPIC_TYPE")} - <a href="${n:out("topicrow.U_VIEW_TOPIC")}" class="topictitle"> - ${n:out("topicrow.TOPIC_TITLE")} - </a> - </span> - <span class="gensmall"> - <br/> - ${n:out("topicrow.GOTO_PAGE")} - </span> - </td> - <td class="row2" align="center" valign="middle"> - <span class="postdetails"> - ${n:out("topicrow.REPLIES")} - </span> - </td> - <td class="row3" align="center" valign="middle"> - <span class="name"> - ${n:out("topicrow.TOPIC_AUTHOR")} - </span> - </td> - <td class="row2" align="center" valign="middle"> - <span class="postdetails"> - ${n:out("topicrow.VIEWS")} - </span> - </td> - <td class="row3Right" align="center" valign="middle" nowrap="nowrap"> - <span class="postdetails"> - ${n:out("topicrow.LAST_POST_TIME")} - <br/> - <n:if ctx="user_auth"> - <a href="${n:out("topicrow.user_auth.POSTER_INFO_LINK")}"> - </n:if> - ${n:out("topicrow.LAST_POST_AUTHOR")} - <n:if ctx="user_auth"></a></n:if> - ${n:out("topicrow.LAST_POST_IMG")} - </span> - </td> - </tr> - </n:iterate> - <n:iterate ctx="switch_no_topics"> - <tr> - <td class="row1" colspan="6" height="30" align="center" valign="middle"> - <span class="gen"> - ${n:out("L_NO_TOPICS")} - </span> - </td> - </tr> - </n:iterate--> + <c:choose> + <c:when test="#{forum.forum.topicCount>0}"> + <c:if test="#{forum.announcementsPresent}"> + <!-- Announcement threads --> + <tr> + <td class="catLeft" colspan="2" height="28"> + <span class="cattitle"> + <a href="" class="cattitle"> + <span>Announcements</span> + </a> + </span> + </td> + <td class="rowpic" colspan="3" align="right">&nbsp;</td> + </tr> + <c:forEach items="#{forum.announcements}" var="topicrow"> + <tr> + <td class="row1" align="center" valign="middle" width="20"> + <img src="#{forums:folderTypeURL(topicrow,forum.anonymous)}" width="19" height="18" + alt="${resource.Topic_Moved}" title="${resource.Topic_Moved}"/> + </td> + <td class="row1" width="100%"> + <span class="topictitle"> + <!-- view newest post image --> + <h:outputLink value="#{forums:outputLink(shared.links['topic'],true)}" style="text-decoration: none;" + alt="#{resource.View_latest_post}" title="#{resource.View_latest_post}"> + <f:param name="t" value="#{topicrow.lastPost.topic.id}"/> + <f:verbatim> + <img border="0" src="#{forums:themeURL('resourceIconLatestReplyURL')}"/> + </f:verbatim> + </h:outputLink> + <!-- topicType --> + <b>Announcement:</b> + <!-- description of the topic --> + <h:outputLink value="#{forums:outputLink(shared.links['topic'],true)}" styleClass="topictitle"> + <f:param name="t" value="${topicrow.id}"/> + <h:outputText value="${topicrow.subject}"/> + </h:outputLink> + </span> + </td> + <td class="row2" align="center" valign="middle"> + <span class="postdetails"> + ${topicrow.replies} + </span> + </td> + <td class="row3" align="center" valign="middle"> + <span class="name"> + ${topicrow.firstPost.poster.user.userName} + </span> + </td> + <td class="row2" align="center" valign="middle"> + <span class="postdetails"> + ${topicrow.viewCount} + </span> + </td> + <td class="row3Right" align="center" valign="middle" nowrap="nowrap"> + <span class="postdetails"> + <!-- date of the last post on this topic --> + #{forums:dateStr(topicrow.lastPostDate)} + <br/> + <!-- last post poster on this topic --> + <c:choose> + <c:when test="#{forum.anonymous}"> + ${topicrow.lastPost.poster.user.userName} + </c:when> + <c:otherwise> + <h:outputLink value="#{forums:outputLink(shared.links['profile'],true)}"> + <f:param name="uid" value="#{topicrow.lastPost.poster.user.id}"/> + <h:outputText value="${topicrow.lastPost.poster.user.userName}"/> + </h:outputLink> + </c:otherwise> + </c:choose> + <!-- link to the last post in the topic --> + <h:outputLink value="#{forums:outputLink(shared.links['topic'],true)}" style="text-decoration: none;" + alt="#{resource.View_latest_post}" title="#{resource.View_latest_post}"> + <f:param name="t" value="#{topicrow.lastPost.topic.id}"/> + <f:verbatim> + <img border="0" src="#{forums:themeURL('resourceIconLatestReplyURL')}"/> + </f:verbatim> + </h:outputLink> + </span> + </td> + </tr> + </c:forEach> + </c:if> + <c:if test="#{forum.stickyThreadsPresent}"> + <!-- Sticky Threads --> + <tr> + <td class="catLeft" colspan="2" height="28"> + <span class="cattitle"> + <a href="" class="cattitle"> + <span>Sticky Threads</span> + </a> + </span> + </td> + <td class="rowpic" colspan="3" align="right">&nbsp;</td> + </tr> + <c:forEach items="#{forum.stickyThreads}" var="topicrow"> + <tr> + <td class="row1" align="center" valign="middle" width="20"> + <img src="#{forums:folderTypeURL(topicrow,forum.anonymous)}" width="19" height="18" + alt="${resource.Topic_Moved}" title="${resource.Topic_Moved}"/> + </td> + <td class="row1" width="100%"> + <span class="topictitle"> + <!-- view newest post image --> + <h:outputLink value="#{forums:outputLink(shared.links['topic'],true)}" style="text-decoration: none;" + alt="#{resource.View_latest_post}" title="#{resource.View_latest_post}"> + <f:param name="t" value="#{topicrow.lastPost.topic.id}"/> + <f:verbatim> + <img border="0" src="#{forums:themeURL('resourceIconLatestReplyURL')}"/> + </f:verbatim> + </h:outputLink> + <!-- topicType --> + <b>Sticky:</b> + <!-- description of the topic --> + <h:outputLink value="#{forums:outputLink(shared.links['topic'],true)}" styleClass="topictitle"> + <f:param name="t" value="${topicrow.id}"/> + <h:outputText value="${topicrow.subject}"/> + </h:outputLink> + </span> + </td> + <td class="row2" align="center" valign="middle"> + <span class="postdetails"> + ${topicrow.replies} + </span> + </td> + <td class="row3" align="center" valign="middle"> + <span class="name"> + ${topicrow.firstPost.poster.user.userName} + </span> + </td> + <td class="row2" align="center" valign="middle"> + <span class="postdetails"> + ${topicrow.viewCount} + </span> + </td> + <td class="row3Right" align="center" valign="middle" nowrap="nowrap"> + <span class="postdetails"> + <!-- date of the last post on this topic --> + #{forums:dateStr(topicrow.lastPostDate)} + <br/> + <!-- last post poster on this topic --> + <c:choose> + <c:when test="#{forum.anonymous}"> + ${topicrow.lastPost.poster.user.userName} + </c:when> + <c:otherwise> + <h:outputLink value="#{forums:outputLink(shared.links['profile'],true)}"> + <f:param name="uid" value="#{topicrow.lastPost.poster.user.id}"/> + <h:outputText value="${topicrow.lastPost.poster.user.userName}"/> + </h:outputLink> + </c:otherwise> + </c:choose> + <!-- link to the last post in the topic --> + <h:outputLink value="#{forums:outputLink(shared.links['topic'],true)}" style="text-decoration: none;" + alt="#{resource.View_latest_post}" title="#{resource.View_latest_post}"> + <f:param name="t" value="#{topicrow.lastPost.topic.id}"/> + <f:verbatim> + <img border="0" src="#{forums:themeURL('resourceIconLatestReplyURL')}"/> + </f:verbatim> + </h:outputLink> + </span> + </td> + </tr> + </c:forEach> + </c:if> + <c:if test="#{forum.normalThreadsPresent}"> + <!-- Normal threads --> + <tr> + <td class="catLeft" colspan="2" height="28"> + <span class="cattitle"> + <a href="" class="cattitle"> + <span>Normal Threads</span> + </a> + </span> + </td> + <td class="rowpic" colspan="3" align="right">&nbsp;</td> + </tr> + <c:forEach items="#{forum.normalThreads}" var="topicrow"> + <tr> + <td class="row1" align="center" valign="middle" width="20"> + <img src="#{forums:folderTypeURL(topicrow,forum.anonymous)}" width="19" height="18" + alt="${resource.Topic_Moved}" title="${resource.Topic_Moved}"/> + </td> + <td class="row1" width="100%"> + <span class="topictitle"> + <!-- view newest post image --> + <h:outputLink value="#{forums:outputLink(shared.links['topic'],true)}" style="text-decoration: none;" + alt="#{resource.View_latest_post}" title="#{resource.View_latest_post}"> + <f:param name="t" value="#{topicrow.lastPost.topic.id}"/> + <f:verbatim> + <img border="0" src="#{forums:themeURL('resourceIconLatestReplyURL')}"/> + </f:verbatim> + </h:outputLink> + <!-- topicType (Normal) no need to specify --> + <!-- description of the topic --> + <h:outputLink value="#{forums:outputLink(shared.links['topic'],true)}" styleClass="topictitle"> + <f:param name="t" value="${topicrow.id}"/> + <h:outputText value="${topicrow.subject}"/> + </h:outputLink> + </span> + </td> + <td class="row2" align="center" valign="middle"> + <span class="postdetails"> + ${topicrow.replies} + </span> + </td> + <td class="row3" align="center" valign="middle"> + <span class="name"> + ${topicrow.firstPost.poster.user.userName} + </span> + </td> + <td class="row2" align="center" valign="middle"> + <span class="postdetails"> + ${topicrow.viewCount} + </span> + </td> + <td class="row3Right" align="center" valign="middle" nowrap="nowrap"> + <span class="postdetails"> + <!-- date of the last post on this topic --> + #{forums:dateStr(topicrow.lastPostDate)} + <br/> + <!-- last post poster on this topic --> + <c:choose> + <c:when test="#{forum.anonymous}"> + ${topicrow.lastPost.poster.user.userName} + </c:when> + <c:otherwise> + <h:outputLink value="#{forums:outputLink(shared.links['profile'],true)}"> + <f:param name="uid" value="#{topicrow.lastPost.poster.user.id}"/> + <h:outputText value="${topicrow.lastPost.poster.user.userName}"/> + </h:outputLink> + </c:otherwise> + </c:choose> + <!-- link to the last post in the topic --> + <h:outputLink value="#{forums:outputLink(shared.links['topic'],true)}" style="text-decoration: none;" + alt="#{resource.View_latest_post}" title="#{resource.View_latest_post}"> + <f:param name="t" value="#{topicrow.lastPost.topic.id}"/> + <f:verbatim> + <img border="0" src="#{forums:themeURL('resourceIconLatestReplyURL')}"/> + </f:verbatim> + </h:outputLink> + </span> + </td> + </tr> + </c:forEach> + </c:if> + </c:when> + <c:otherwise> + <tr> + <td class="row1" colspan="6" height="30" align="center" valign="middle"> + <span class="gen"> + ${resource.No_topics_post_one} + </span> + </td> + </tr> + </c:otherwise> + </c:choose> </table> + <!-- newtopic, forum, and page navigation --> <table width="100%" cellspacing="2" border="0" align="center" cellpadding="2"> <tr> <td align="left" valign="middle" width="50"> @@ -252,23 +454,74 @@ </h:outputLink> </span> </td> - <td align="right" valign="middle" nowrap="nowrap"> - <span class="gensmall"></span> - <br/> - <span class="nav"> - #{forum.pagination} - </span> - </td> + <!-- page navigation --> + <c:if test="#{forum.pageNavigator.totalPages gt 1}"> + <td align="right" valign="middle" nowrap="nowrap"> + <span class="gensmall"></span><br/> + <span class="nav"> + Goto page + <!-- previous link --> + <c:if test="#{forum.pageNavigator.pageNumber gt 1}"> + &nbsp;&nbsp; + <h:outputLink value="#{forums:outputLink(shared.links['forum'],true)}"> + <f:param name="f" value="#{forum.forum.id}"/> + <f:param name="page" value="#{forum.pageNavigator.currentPage-1}"/> + <h:outputText value="Previous"/> + </h:outputLink> + &nbsp;&nbsp; + </c:if> + <!-- actual pages --> + <c:forEach items="#{forum.pageNavigator.pages}" var="page" varStatus="idx"> + <c:choose> + <c:when test="#{forum.pageNavigator.pageNumber==page}"> + <b>${page}</b> + </c:when> + <c:otherwise> + <h:outputLink value="#{forums:outputLink(shared.links['forum'],true)}"> + <f:param name="f" value="#{forum.forum.id}"/> + <f:param name="page" value="#{page-1}"/> + <h:outputText value="${page}"/> + </h:outputLink> + </c:otherwise> + </c:choose> + <c:if test="${idx.index-1 ne forum.pageNavigator.totalPages-1}"> + <f:verbatim>,</f:verbatim> + </c:if> + </c:forEach> + <!-- Next link --> + <c:if test="#{forum.pageNavigator.pageNumber lt forum.pageNavigator.totalPages}"> + &nbsp;&nbsp; + <h:outputLink value="#{forums:outputLink(shared.links['forum'],true)}"> + <f:param name="f" value="#{forum.forum.id}"/> + <f:param name="page" value="#{forum.pageNavigator.currentPage+1}"/> + <h:outputText value="Next"/> + </h:outputLink> + &nbsp;&nbsp; + </c:if> + </span> + </td> + </c:if> </tr> - <tr> - <td align="left" colspan="3"> - <span class="nav"> - #{forum.pageNumber} - </span> - </td> - </tr> - </table> + <!-- the current page number information --> + <c:if test="#{forum.pageNavigator.totalPages gt 1}"> + <tr> + <td>&nbsp;</td> + </tr> + <tr> + <td align="left" colspan="3"> + <span class="nav"> + Page <b>#{forum.pageNavigator.pageNumber}</b> of <b>#{forum.pageNavigator.totalPages}</b> + </span> + </td> + </tr> + <tr> + <td>&nbsp;</td> + </tr> + </c:if> + </table> + + <!-- displaying icons, permissions, and jumpbox --> <table width="100%" cellspacing="0" border="0" align="center" cellpadding="0"> <tr> <td align="left" valign="top"> @@ -319,10 +572,19 @@ </table> </td> <td align="right"> - <span class="gensmall"> - <ui:include src="/views/jumpbox.xhtml"/> - <!-- TODO: hookup real data here...need to extract out the hardcoded html code from the original portlet --> - <!-- S_AUTH_LIST --> + <span class="gensmall"> + <!-- a list of allowed actions on this forum for this user --> + <span class="gensmall"> + <!-- TODO: insert security check to make sure "posting new topics" is allowed in "this forum" --> + You <b>cannot</b> post new topics in this forum <br/> + <!-- TODO: insert security check to make sure "poll creation" is allowed in "this forum" --> + You <b>cannot</b> create polls in this forum <br/> + <!-- TODO: insert security check to make sure "placing votes" is allowed in "this forum" --> + You <b>cannot</b> vote in polls in this forum <br/> + <!-- TODO: insert security check to make sure "moderator access" is allowed on "this forum" --> + You <b>cannot</b> moderate this forum <b/> + </span> + <ui:include src="/views/jumpbox.xhtml"/> </span> </td> </tr> |
From: <jbo...@li...> - 2006-05-15 12:29:38
|
Author: mar...@jb... Date: 2006-05-15 08:29:34 -0400 (Mon, 15 May 2006) New Revision: 4228 Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java Log: -Changed incorrect case in test name Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java 2006-05-15 11:40:43 UTC (rev 4227) +++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java 2006-05-15 12:29:34 UTC (rev 4228) @@ -221,7 +221,7 @@ public void testPropertyChangeSupport() throws Exception { PackageBuilder builder = new PackageBuilder(); - builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "Test_PropertyChange.drl" ) ) ); + builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_PropertyChange.drl" ) ) ); Package pkg = builder.getPackage(); RuleBase ruleBase = getRuleBase(); |
From: <jbo...@li...> - 2006-05-15 11:40:48
|
Author: mar...@jb... Date: 2006-05-15 07:40:43 -0400 (Mon, 15 May 2006) New Revision: 4227 Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_ActivationGroups.drl Log: -Change xor-group to activation-group Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java 2006-05-15 11:36:03 UTC (rev 4226) +++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java 2006-05-15 11:40:43 UTC (rev 4227) @@ -1147,7 +1147,7 @@ public void testXorGroups() throws Exception { PackageBuilder builder = new PackageBuilder(); - builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_XorGroups.drl" ) ) ); + builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_ActivationGroups.drl" ) ) ); Package pkg = builder.getPackage(); RuleBase ruleBase = getRuleBase(); Modified: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_ActivationGroups.drl =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_ActivationGroups.drl 2006-05-15 11:36:03 UTC (rev 4226) +++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_ActivationGroups.drl 2006-05-15 11:40:43 UTC (rev 4227) @@ -30,7 +30,7 @@ rule "rule3" agenda-group "agenda-group-3" - activation-group "activatino-group-3" + activation-group "activation-group-3" when Cheese( ) then |
From: <jbo...@li...> - 2006-05-15 11:36:21
|
Author: mic...@jb... Date: 2006-05-15 07:36:03 -0400 (Mon, 15 May 2006) New Revision: 4226 Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/RuleParser.java labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/RuleParserLexer.java Log: rebuilt for activation group Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/RuleParser.java =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/RuleParser.java 2006-05-15 11:29:49 UTC (rev 4225) +++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/RuleParser.java 2006-05-15 11:36:03 UTC (rev 4226) @@ -1,4 +1,4 @@ -// $ANTLR 3.0ea8 C:\Projects\jboss-rules-new\drools-compiler\src\main\resources\org\drools\lang\drl.g 2006-05-10 10:15:08 +// $ANTLR 3.0ea8 C:\Projects\jboss-rules-new\drools-compiler\src\main\resources\org\drools\lang\drl.g 2006-05-15 21:35:31 package org.drools.lang; import java.util.List; @@ -15,7 +15,7 @@ public class RuleParser extends Parser { public static final String[] tokenNames = new String[] { - "<invalid>", "<EOR>", "<DOWN>", "<UP>", "EOL", "ID", "INT", "BOOL", "STRING", "FLOAT", "MISC", "WS", "SH_STYLE_SINGLE_LINE_COMMENT", "C_STYLE_SINGLE_LINE_COMMENT", "MULTI_LINE_COMMENT", "\';\'", "\'package\'", "\'import\'", "\'.\'", "\'.*\'", "\'expander\'", "\'global\'", "\'function\'", "\'(\'", "\',\'", "\')\'", "\'{\'", "\'}\'", "\'query\'", "\'end\'", "\'rule\'", "\'when\'", "\':\'", "\'then\'", "\'attributes\'", "\'salience\'", "\'no-loop\'", "\'auto-focus\'", "\'xor-group\'", "\'agenda-group\'", "\'duration\'", "\'or\'", "\'==\'", "\'>\'", "\'>=\'", "\'<\'", "\'<=\'", "\'!=\'", "\'contains\'", "\'matches\'", "\'excludes\'", "\'null\'", "\'->\'", "\'||\'", "\'and\'", "\'&&\'", "\'exists\'", "\'not\'", "\'eval\'", "\'[\'", "\']\'", "\'use\'" + "<invalid>", "<EOR>", "<DOWN>", "<UP>", "EOL", "ID", "INT", "BOOL", "STRING", "FLOAT", "MISC", "WS", "SH_STYLE_SINGLE_LINE_COMMENT", "C_STYLE_SINGLE_LINE_COMMENT", "MULTI_LINE_COMMENT", "\';\'", "\'package\'", "\'import\'", "\'.\'", "\'.*\'", "\'expander\'", "\'global\'", "\'function\'", "\'(\'", "\',\'", "\')\'", "\'{\'", "\'}\'", "\'query\'", "\'end\'", "\'rule\'", "\'when\'", "\':\'", "\'then\'", "\'attributes\'", "\'salience\'", "\'no-loop\'", "\'auto-focus\'", "\'activation-group\'", "\'agenda-group\'", "\'duration\'", "\'or\'", "\'==\'", "\'>\'", "\'>=\'", "\'<\'", "\'<=\'", "\'!=\'", "\'contains\'", "\'matches\'", "\'excludes\'", "\'null\'", "\'->\'", "\'||\'", "\'and\'", "\'&&\'", "\'exists\'", "\'not\'", "\'eval\'", "\'[\'", "\']\'", "\'use\'" }; public static final int BOOL=7; public static final int INT=6; @@ -2128,7 +2128,7 @@ // $ANTLR start rule_attribute - // C:\Projects\jboss-rules-new\drools-compiler\src\main\resources\org\drools\lang\drl.g:455:1: rule_attribute returns [AttributeDescr d] : (a= salience | a= no_loop | a= agenda_group | a= duration | a= xor_group | a= auto_focus ); + // C:\Projects\jboss-rules-new\drools-compiler\src\main\resources\org\drools\lang\drl.g:455:1: rule_attribute returns [AttributeDescr d] : (a= salience | a= no_loop | a= agenda_group | a= duration | a= activation_group | a= auto_focus ); public AttributeDescr rule_attribute() throws RecognitionException { AttributeDescr d; AttributeDescr a = null; @@ -2138,7 +2138,7 @@ d = null; try { - // C:\Projects\jboss-rules-new\drools-compiler\src\main\resources\org\drools\lang\drl.g:460:25: (a= salience | a= no_loop | a= agenda_group | a= duration | a= xor_group | a= auto_focus ) + // C:\Projects\jboss-rules-new\drools-compiler\src\main\resources\org\drools\lang\drl.g:460:25: (a= salience | a= no_loop | a= agenda_group | a= duration | a= activation_group | a= auto_focus ) int alt31=6; switch ( input.LA(1) ) { case 35: @@ -2161,7 +2161,7 @@ break; default: NoViableAltException nvae = - new NoViableAltException("455:1: rule_attribute returns [AttributeDescr d] : (a= salience | a= no_loop | a= agenda_group | a= duration | a= xor_group | a= auto_focus );", 31, 0, input); + new NoViableAltException("455:1: rule_attribute returns [AttributeDescr d] : (a= salience | a= no_loop | a= agenda_group | a= duration | a= activation_group | a= auto_focus );", 31, 0, input); throw nvae; } @@ -2212,10 +2212,10 @@ } break; case 5 : - // C:\Projects\jboss-rules-new\drools-compiler\src\main\resources\org\drools\lang\drl.g:464:25: a= xor_group + // C:\Projects\jboss-rules-new\drools-compiler\src\main\resources\org\drools\lang\drl.g:464:25: a= activation_group { - following.push(FOLLOW_xor_group_in_rule_attribute909); - a=xor_group(); + following.push(FOLLOW_activation_group_in_rule_attribute909); + a=activation_group(); following.pop(); d = a; @@ -2630,9 +2630,9 @@ // $ANTLR end auto_focus - // $ANTLR start xor_group - // C:\Projects\jboss-rules-new\drools-compiler\src\main\resources\org\drools\lang\drl.g:529:1: xor_group returns [AttributeDescr d] : loc= 'xor-group' opt_eol name= STRING ( ';' )? opt_eol ; - public AttributeDescr xor_group() throws RecognitionException { + // $ANTLR start activation_group + // C:\Projects\jboss-rules-new\drools-compiler\src\main\resources\org\drools\lang\drl.g:529:1: activation_group returns [AttributeDescr d] : loc= 'activation-group' opt_eol name= STRING ( ';' )? opt_eol ; + public AttributeDescr activation_group() throws RecognitionException { AttributeDescr d; Token loc=null; Token name=null; @@ -2641,18 +2641,18 @@ d = null; try { - // C:\Projects\jboss-rules-new\drools-compiler\src\main\resources\org\drools\lang\drl.g:534:17: (loc= 'xor-group' opt_eol name= STRING ( ';' )? opt_eol ) - // C:\Projects\jboss-rules-new\drools-compiler\src\main\resources\org\drools\lang\drl.g:534:17: loc= 'xor-group' opt_eol name= STRING ( ';' )? opt_eol + // C:\Projects\jboss-rules-new\drools-compiler\src\main\resources\org\drools\lang\drl.g:534:17: (loc= 'activation-group' opt_eol name= STRING ( ';' )? opt_eol ) + // C:\Projects\jboss-rules-new\drools-compiler\src\main\resources\org\drools\lang\drl.g:534:17: loc= 'activation-group' opt_eol name= STRING ( ';' )? opt_eol { loc=(Token)input.LT(1); - match(input,38,FOLLOW_38_in_xor_group1173); - following.push(FOLLOW_opt_eol_in_xor_group1175); + match(input,38,FOLLOW_38_in_activation_group1173); + following.push(FOLLOW_opt_eol_in_activation_group1175); opt_eol(); following.pop(); name=(Token)input.LT(1); - match(input,STRING,FOLLOW_STRING_in_xor_group1179); - // C:\Projects\jboss-rules-new\drools-compiler\src\main\resources\org\drools\lang\drl.g:534:53: ( ';' )? + match(input,STRING,FOLLOW_STRING_in_activation_group1179); + // C:\Projects\jboss-rules-new\drools-compiler\src\main\resources\org\drools\lang\drl.g:534:60: ( ';' )? int alt39=2; int LA39_0 = input.LA(1); if ( LA39_0==15 ) { @@ -2663,27 +2663,27 @@ } else { NoViableAltException nvae = - new NoViableAltException("534:53: ( \';\' )?", 39, 0, input); + new NoViableAltException("534:60: ( \';\' )?", 39, 0, input); throw nvae; } switch (alt39) { case 1 : - // C:\Projects\jboss-rules-new\drools-compiler\src\main\resources\org\drools\lang\drl.g:534:53: ';' + // C:\Projects\jboss-rules-new\drools-compiler\src\main\resources\org\drools\lang\drl.g:534:60: ';' { - match(input,15,FOLLOW_15_in_xor_group1181); + match(input,15,FOLLOW_15_in_activation_group1181); } break; } - following.push(FOLLOW_opt_eol_in_xor_group1184); + following.push(FOLLOW_opt_eol_in_activation_group1184); opt_eol(); following.pop(); - d = new AttributeDescr( "xor-group", getString( name ) ); + d = new AttributeDescr( "activation-group", getString( name ) ); d.setLocation( offset(loc.getLine()), loc.getCharPositionInLine() ); @@ -2698,7 +2698,7 @@ } return d; } - // $ANTLR end xor_group + // $ANTLR end activation_group // $ANTLR start agenda_group @@ -7310,7 +7310,7 @@ public static final BitSet FOLLOW_no_loop_in_rule_attribute871 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_agenda_group_in_rule_attribute882 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_duration_in_rule_attribute895 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_xor_group_in_rule_attribute909 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_activation_group_in_rule_attribute909 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_auto_focus_in_rule_attribute920 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_35_in_salience953 = new BitSet(new long[]{0x0000000000008012L}); public static final BitSet FOLLOW_opt_eol_in_salience955 = new BitSet(new long[]{0x0000000000000040L}); @@ -7335,11 +7335,11 @@ public static final BitSet FOLLOW_opt_eol_in_auto_focus1126 = new BitSet(new long[]{0x0000000000008012L}); public static final BitSet FOLLOW_15_in_auto_focus1128 = new BitSet(new long[]{0x0000000000008012L}); public static final BitSet FOLLOW_opt_eol_in_auto_focus1131 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_38_in_xor_group1173 = new BitSet(new long[]{0x0000000000008012L}); - public static final BitSet FOLLOW_opt_eol_in_xor_group1175 = new BitSet(new long[]{0x0000000000000100L}); - public static final BitSet FOLLOW_STRING_in_xor_group1179 = new BitSet(new long[]{0x0000000000008012L}); - public static final BitSet FOLLOW_15_in_xor_group1181 = new BitSet(new long[]{0x0000000000008012L}); - public static final BitSet FOLLOW_opt_eol_in_xor_group1184 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_38_in_activation_group1173 = new BitSet(new long[]{0x0000000000008012L}); + public static final BitSet FOLLOW_opt_eol_in_activation_group1175 = new BitSet(new long[]{0x0000000000000100L}); + public static final BitSet FOLLOW_STRING_in_activation_group1179 = new BitSet(new long[]{0x0000000000008012L}); + public static final BitSet FOLLOW_15_in_activation_group1181 = new BitSet(new long[]{0x0000000000008012L}); + public static final BitSet FOLLOW_opt_eol_in_activation_group1184 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_39_in_agenda_group1213 = new BitSet(new long[]{0x0000000000008012L}); public static final BitSet FOLLOW_opt_eol_in_agenda_group1215 = new BitSet(new long[]{0x0000000000000100L}); public static final BitSet FOLLOW_STRING_in_agenda_group1219 = new BitSet(new long[]{0x0000000000008012L}); Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/RuleParserLexer.java =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/RuleParserLexer.java 2006-05-15 11:29:49 UTC (rev 4225) +++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/RuleParserLexer.java 2006-05-15 11:36:03 UTC (rev 4226) @@ -1,4 +1,4 @@ -// $ANTLR 3.0ea8 C:\Projects\jboss-rules-new\drools-compiler\src\main\resources\org\drools\lang\drl.g 2006-05-10 10:15:09 +// $ANTLR 3.0ea8 C:\Projects\jboss-rules-new\drools-compiler\src\main\resources\org\drools\lang\drl.g 2006-05-15 21:35:31 package org.drools.lang; @@ -701,10 +701,10 @@ int charPosition = getCharPositionInLine(); int channel = Token.DEFAULT_CHANNEL; if ( backtracking>0 && alreadyParsedRule(input, 24) ) { return ; } - // C:\Projects\jboss-rules-new\drools-compiler\src\main\resources\org\drools\lang\drl.g:29:7: ( 'xor-group' ) - // C:\Projects\jboss-rules-new\drools-compiler\src\main\resources\org\drools\lang\drl.g:29:7: 'xor-group' + // C:\Projects\jboss-rules-new\drools-compiler\src\main\resources\org\drools\lang\drl.g:29:7: ( 'activation-group' ) + // C:\Projects\jboss-rules-new\drools-compiler\src\main\resources\org\drools\lang\drl.g:29:7: 'activation-group' { - match("xor-group"); if (failed) return ; + match("activation-group"); if (failed) return ; } @@ -1434,17 +1434,17 @@ case '+': alt1=31; break; + case '-': + alt1=33; + break; case '=': alt1=29; break; - case '*': - alt1=35; - break; case '/': alt1=37; break; - case '-': - alt1=33; + case '*': + alt1=35; break; default: alt1=17;} @@ -2995,285 +2995,302 @@ return predict(input, s0); } DFA.State s1 = new DFA.State() {{alt=1;}}; - DFA.State s460 = new DFA.State() {{alt=2;}}; - DFA.State s51 = new DFA.State() {{alt=55;}}; - DFA.State s424 = new DFA.State() { + DFA.State s466 = new DFA.State() {{alt=2;}}; + DFA.State s50 = new DFA.State() {{alt=55;}}; + DFA.State s427 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_424 = input.LA(1); - if ( (LA16_424>='0' && LA16_424<='9')||(LA16_424>='A' && LA16_424<='Z')||LA16_424=='_'||(LA16_424>='a' && LA16_424<='z')||(LA16_424>='\u00C0' && LA16_424<='\u00FF') ) {return s51;} - return s460; + int LA16_427 = input.LA(1); + if ( (LA16_427>='0' && LA16_427<='9')||(LA16_427>='A' && LA16_427<='Z')||LA16_427=='_'||(LA16_427>='a' && LA16_427<='z')||(LA16_427>='\u00C0' && LA16_427<='\u00FF') ) {return s50;} + return s466; } }; DFA.State s381 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { int LA16_381 = input.LA(1); - if ( LA16_381=='e' ) {return s424;} - return s51; + if ( LA16_381=='e' ) {return s427;} + return s50; } }; - DFA.State s321 = new DFA.State() { + DFA.State s318 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_321 = input.LA(1); - if ( LA16_321=='g' ) {return s381;} - return s51; + int LA16_318 = input.LA(1); + if ( LA16_318=='g' ) {return s381;} + return s50; } }; - DFA.State s244 = new DFA.State() { + DFA.State s241 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_244 = input.LA(1); - if ( LA16_244=='a' ) {return s321;} - return s51; + int LA16_241 = input.LA(1); + if ( LA16_241=='a' ) {return s318;} + return s50; } }; - DFA.State s161 = new DFA.State() { + DFA.State s158 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_161 = input.LA(1); - if ( LA16_161=='k' ) {return s244;} - return s51; + int LA16_158 = input.LA(1); + if ( LA16_158=='k' ) {return s241;} + return s50; } }; - DFA.State s53 = new DFA.State() { + DFA.State s52 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_53 = input.LA(1); - if ( LA16_53=='c' ) {return s161;} - return s51; + int LA16_52 = input.LA(1); + if ( LA16_52=='c' ) {return s158;} + return s50; } }; DFA.State s2 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { int LA16_2 = input.LA(1); - if ( LA16_2=='a' ) {return s53;} - return s51; + if ( LA16_2=='a' ) {return s52;} + return s50; } }; - DFA.State s427 = new DFA.State() {{alt=3;}}; + DFA.State s430 = new DFA.State() {{alt=3;}}; DFA.State s384 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { int LA16_384 = input.LA(1); - if ( (LA16_384>='0' && LA16_384<='9')||(LA16_384>='A' && LA16_384<='Z')||LA16_384=='_'||(LA16_384>='a' && LA16_384<='z')||(LA16_384>='\u00C0' && LA16_384<='\u00FF') ) {return s51;} - return s427; + if ( (LA16_384>='0' && LA16_384<='9')||(LA16_384>='A' && LA16_384<='Z')||LA16_384=='_'||(LA16_384>='a' && LA16_384<='z')||(LA16_384>='\u00C0' && LA16_384<='\u00FF') ) {return s50;} + return s430; } }; - DFA.State s324 = new DFA.State() { + DFA.State s321 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_324 = input.LA(1); - if ( LA16_324=='t' ) {return s384;} - return s51; + int LA16_321 = input.LA(1); + if ( LA16_321=='t' ) {return s384;} + return s50; } }; - DFA.State s247 = new DFA.State() { + DFA.State s244 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_247 = input.LA(1); - if ( LA16_247=='r' ) {return s324;} - return s51; + int LA16_244 = input.LA(1); + if ( LA16_244=='r' ) {return s321;} + return s50; } }; - DFA.State s164 = new DFA.State() { + DFA.State s161 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_164 = input.LA(1); - if ( LA16_164=='o' ) {return s247;} - return s51; + int LA16_161 = input.LA(1); + if ( LA16_161=='o' ) {return s244;} + return s50; } }; - DFA.State s56 = new DFA.State() { + DFA.State s55 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_56 = input.LA(1); - if ( LA16_56=='p' ) {return s164;} - return s51; + int LA16_55 = input.LA(1); + if ( LA16_55=='p' ) {return s161;} + return s50; } }; DFA.State s3 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { int LA16_3 = input.LA(1); - if ( LA16_3=='m' ) {return s56;} - return s51; + if ( LA16_3=='m' ) {return s55;} + return s50; } }; - DFA.State s59 = new DFA.State() {{alt=5;}}; - DFA.State s60 = new DFA.State() {{alt=4;}}; + DFA.State s58 = new DFA.State() {{alt=5;}}; + DFA.State s59 = new DFA.State() {{alt=4;}}; DFA.State s4 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { int LA16_4 = input.LA(1); - if ( LA16_4=='*' ) {return s59;} - return s60; + if ( LA16_4=='*' ) {return s58;} + return s59; } }; - DFA.State s485 = new DFA.State() {{alt=36;}}; - DFA.State s462 = new DFA.State() { + DFA.State s247 = new DFA.State() {{alt=15;}}; + DFA.State s164 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_462 = input.LA(1); - if ( (LA16_462>='0' && LA16_462<='9')||(LA16_462>='A' && LA16_462<='Z')||LA16_462=='_'||(LA16_462>='a' && LA16_462<='z')||(LA16_462>='\u00C0' && LA16_462<='\u00FF') ) {return s51;} - return s485; + int LA16_164 = input.LA(1); + if ( (LA16_164>='0' && LA16_164<='9')||(LA16_164>='A' && LA16_164<='Z')||LA16_164=='_'||(LA16_164>='a' && LA16_164<='z')||(LA16_164>='\u00C0' && LA16_164<='\u00FF') ) {return s50;} + return s247; } }; - DFA.State s429 = new DFA.State() { + DFA.State s60 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_429 = input.LA(1); - if ( LA16_429=='s' ) {return s462;} - return s51; + int LA16_60 = input.LA(1); + if ( LA16_60=='d' ) {return s164;} + return s50; } }; + DFA.State s432 = new DFA.State() {{alt=42;}}; DFA.State s387 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { int LA16_387 = input.LA(1); - if ( LA16_387=='e' ) {return s429;} - return s51; + if ( (LA16_387>='0' && LA16_387<='9')||(LA16_387>='A' && LA16_387<='Z')||LA16_387=='_'||(LA16_387>='a' && LA16_387<='z')||(LA16_387>='\u00C0' && LA16_387<='\u00FF') ) {return s50;} + return s432; } }; - DFA.State s327 = new DFA.State() { + DFA.State s324 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_327 = input.LA(1); - if ( LA16_327=='d' ) {return s387;} - return s51; + int LA16_324 = input.LA(1); + if ( LA16_324=='s' ) {return s387;} + return s50; } }; - DFA.State s250 = new DFA.State() { + DFA.State s249 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_250 = input.LA(1); - if ( LA16_250=='u' ) {return s327;} - return s51; + int LA16_249 = input.LA(1); + if ( LA16_249=='t' ) {return s324;} + return s50; } }; DFA.State s167 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { int LA16_167 = input.LA(1); - if ( LA16_167=='l' ) {return s250;} - return s51; + if ( LA16_167=='s' ) {return s249;} + return s50; } }; - DFA.State s432 = new DFA.State() {{alt=42;}}; + DFA.State s494 = new DFA.State() {{alt=36;}}; + DFA.State s468 = new DFA.State() { + public DFA.State transition(IntStream input) throws RecognitionException { + int LA16_468 = input.LA(1); + if ( (LA16_468>='0' && LA16_468<='9')||(LA16_468>='A' && LA16_468<='Z')||LA16_468=='_'||(LA16_468>='a' && LA16_468<='z')||(LA16_468>='\u00C0' && LA16_468<='\u00FF') ) {return s50;} + return s494; + + } + }; + DFA.State s434 = new DFA.State() { + public DFA.State transition(IntStream input) throws RecognitionException { + int LA16_434 = input.LA(1); + if ( LA16_434=='s' ) {return s468;} + return s50; + + } + }; DFA.State s390 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { int LA16_390 = input.LA(1); - if ( (LA16_390>='0' && LA16_390<='9')||(LA16_390>='A' && LA16_390<='Z')||LA16_390=='_'||(LA16_390>='a' && LA16_390<='z')||(LA16_390>='\u00C0' && LA16_390<='\u00FF') ) {return s51;} - return s432; + if ( LA16_390=='e' ) {return s434;} + return s50; } }; - DFA.State s330 = new DFA.State() { + DFA.State s327 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_330 = input.LA(1); - if ( LA16_330=='s' ) {return s390;} - return s51; + int LA16_327 = input.LA(1); + if ( LA16_327=='d' ) {return s390;} + return s50; } }; - DFA.State s253 = new DFA.State() { + DFA.State s252 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_253 = input.LA(1); - if ( LA16_253=='t' ) {return s330;} - return s51; + int LA16_252 = input.LA(1); + if ( LA16_252=='u' ) {return s327;} + return s50; } }; DFA.State s168 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { int LA16_168 = input.LA(1); - if ( LA16_168=='s' ) {return s253;} - return s51; + if ( LA16_168=='l' ) {return s252;} + return s50; } }; - DFA.State s487 = new DFA.State() {{alt=6;}}; - DFA.State s465 = new DFA.State() { + DFA.State s496 = new DFA.State() {{alt=6;}}; + DFA.State s471 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_465 = input.LA(1); - if ( (LA16_465>='0' && LA16_465<='9')||(LA16_465>='A' && LA16_465<='Z')||LA16_465=='_'||(LA16_465>='a' && LA16_465<='z')||(LA16_465>='\u00C0' && LA16_465<='\u00FF') ) {return s51;} - return s487; + int LA16_471 = input.LA(1); + if ( (LA16_471>='0' && LA16_471<='9')||(LA16_471>='A' && LA16_471<='Z')||LA16_471=='_'||(LA16_471>='a' && LA16_471<='z')||(LA16_471>='\u00C0' && LA16_471<='\u00FF') ) {return s50;} + return s496; } }; - DFA.State s434 = new DFA.State() { + DFA.State s437 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_434 = input.LA(1); - if ( LA16_434=='r' ) {return s465;} - return s51; + int LA16_437 = input.LA(1); + if ( LA16_437=='r' ) {return s471;} + return s50; } }; DFA.State s393 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { int LA16_393 = input.LA(1); - if ( LA16_393=='e' ) {return s434;} - return s51; + if ( LA16_393=='e' ) {return s437;} + return s50; } }; - DFA.State s333 = new DFA.State() { + DFA.State s330 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_333 = input.LA(1); - if ( LA16_333=='d' ) {return s393;} - return s51; + int LA16_330 = input.LA(1); + if ( LA16_330=='d' ) {return s393;} + return s50; } }; - DFA.State s256 = new DFA.State() { + DFA.State s255 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_256 = input.LA(1); - if ( LA16_256=='n' ) {return s333;} - return s51; + int LA16_255 = input.LA(1); + if ( LA16_255=='n' ) {return s330;} + return s50; } }; DFA.State s169 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { int LA16_169 = input.LA(1); - if ( LA16_169=='a' ) {return s256;} - return s51; + if ( LA16_169=='a' ) {return s255;} + return s50; } }; DFA.State s61 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { switch ( input.LA(1) ) { - case 'c': + case 'i': return s167; - case 'i': + case 'c': return s168; case 'p': return s169; default: - return s51; + return s50; } } }; - DFA.State s336 = new DFA.State() {{alt=44;}}; - DFA.State s259 = new DFA.State() { + DFA.State s333 = new DFA.State() {{alt=44;}}; + DFA.State s258 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_259 = input.LA(1); - if ( (LA16_259>='0' && LA16_259<='9')||(LA16_259>='A' && LA16_259<='Z')||LA16_259=='_'||(LA16_259>='a' && LA16_259<='z')||(LA16_259>='\u00C0' && LA16_259<='\u00FF') ) {return s51;} - return s336; + int LA16_258 = input.LA(1); + if ( (LA16_258>='0' && LA16_258<='9')||(LA16_258>='A' && LA16_258<='Z')||LA16_258=='_'||(LA16_258>='a' && LA16_258<='z')||(LA16_258>='\u00C0' && LA16_258<='\u00FF') ) {return s50;} + return s333; } }; DFA.State s172 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { int LA16_172 = input.LA(1); - if ( LA16_172=='l' ) {return s259;} - return s51; + if ( LA16_172=='l' ) {return s258;} + return s50; } }; @@ -3281,180 +3298,163 @@ public DFA.State transition(IntStream input) throws RecognitionException { int LA16_62 = input.LA(1); if ( LA16_62=='a' ) {return s172;} - return s51; + return s50; } }; - DFA.State s262 = new DFA.State() {{alt=15;}}; - DFA.State s175 = new DFA.State() { - public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_175 = input.LA(1); - if ( (LA16_175>='0' && LA16_175<='9')||(LA16_175>='A' && LA16_175<='Z')||LA16_175=='_'||(LA16_175>='a' && LA16_175<='z')||(LA16_175>='\u00C0' && LA16_175<='\u00FF') ) {return s51;} - return s262; - - } - }; - DFA.State s63 = new DFA.State() { - public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_63 = input.LA(1); - if ( LA16_63=='d' ) {return s175;} - return s51; - - } - }; DFA.State s5 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { switch ( input.LA(1) ) { + case 'n': + return s60; + case 'x': return s61; case 'v': return s62; - case 'n': - return s63; - default: - return s51; + return s50; } } }; - DFA.State s437 = new DFA.State() {{alt=7;}}; + DFA.State s440 = new DFA.State() {{alt=7;}}; DFA.State s396 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { int LA16_396 = input.LA(1); - if ( (LA16_396>='0' && LA16_396<='9')||(LA16_396>='A' && LA16_396<='Z')||LA16_396=='_'||(LA16_396>='a' && LA16_396<='z')||(LA16_396>='\u00C0' && LA16_396<='\u00FF') ) {return s51;} - return s437; + if ( (LA16_396>='0' && LA16_396<='9')||(LA16_396>='A' && LA16_396<='Z')||LA16_396=='_'||(LA16_396>='a' && LA16_396<='z')||(LA16_396>='\u00C0' && LA16_396<='\u00FF') ) {return s50;} + return s440; } }; - DFA.State s338 = new DFA.State() { + DFA.State s335 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_338 = input.LA(1); - if ( LA16_338=='l' ) {return s396;} - return s51; + int LA16_335 = input.LA(1); + if ( LA16_335=='l' ) {return s396;} + return s50; } }; - DFA.State s264 = new DFA.State() { + DFA.State s261 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_264 = input.LA(1); - if ( LA16_264=='a' ) {return s338;} - return s51; + int LA16_261 = input.LA(1); + if ( LA16_261=='a' ) {return s335;} + return s50; } }; - DFA.State s178 = new DFA.State() { + DFA.State s175 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_178 = input.LA(1); - if ( LA16_178=='b' ) {return s264;} - return s51; + int LA16_175 = input.LA(1); + if ( LA16_175=='b' ) {return s261;} + return s50; } }; - DFA.State s66 = new DFA.State() { + DFA.State s65 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_66 = input.LA(1); - if ( LA16_66=='o' ) {return s178;} - return s51; + int LA16_65 = input.LA(1); + if ( LA16_65=='o' ) {return s175;} + return s50; } }; DFA.State s6 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { int LA16_6 = input.LA(1); - if ( LA16_6=='l' ) {return s66;} - return s51; + if ( LA16_6=='l' ) {return s65;} + return s50; } }; - DFA.State s489 = new DFA.State() {{alt=8;}}; - DFA.State s468 = new DFA.State() { + DFA.State s498 = new DFA.State() {{alt=8;}}; + DFA.State s474 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_468 = input.LA(1); - if ( (LA16_468>='0' && LA16_468<='9')||(LA16_468>='A' && LA16_468<='Z')||LA16_468=='_'||(LA16_468>='a' && LA16_468<='z')||(LA16_468>='\u00C0' && LA16_468<='\u00FF') ) {return s51;} - return s489; + int LA16_474 = input.LA(1); + if ( (LA16_474>='0' && LA16_474<='9')||(LA16_474>='A' && LA16_474<='Z')||LA16_474=='_'||(LA16_474>='a' && LA16_474<='z')||(LA16_474>='\u00C0' && LA16_474<='\u00FF') ) {return s50;} + return s498; } }; - DFA.State s439 = new DFA.State() { + DFA.State s442 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_439 = input.LA(1); - if ( LA16_439=='n' ) {return s468;} - return s51; + int LA16_442 = input.LA(1); + if ( LA16_442=='n' ) {return s474;} + return s50; } }; DFA.State s399 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { int LA16_399 = input.LA(1); - if ( LA16_399=='o' ) {return s439;} - return s51; + if ( LA16_399=='o' ) {return s442;} + return s50; } }; - DFA.State s341 = new DFA.State() { + DFA.State s338 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_341 = input.LA(1); - if ( LA16_341=='i' ) {return s399;} - return s51; + int LA16_338 = input.LA(1); + if ( LA16_338=='i' ) {return s399;} + return s50; } }; - DFA.State s267 = new DFA.State() { + DFA.State s264 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_267 = input.LA(1); - if ( LA16_267=='t' ) {return s341;} - return s51; + int LA16_264 = input.LA(1); + if ( LA16_264=='t' ) {return s338;} + return s50; } }; - DFA.State s181 = new DFA.State() { + DFA.State s178 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_181 = input.LA(1); - if ( LA16_181=='c' ) {return s267;} - return s51; + int LA16_178 = input.LA(1); + if ( LA16_178=='c' ) {return s264;} + return s50; } }; - DFA.State s69 = new DFA.State() { + DFA.State s68 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_69 = input.LA(1); - if ( LA16_69=='n' ) {return s181;} - return s51; + int LA16_68 = input.LA(1); + if ( LA16_68=='n' ) {return s178;} + return s50; } }; - DFA.State s354 = new DFA.State() {{alt=54;}}; - DFA.State s344 = new DFA.State() { + DFA.State s353 = new DFA.State() {{alt=54;}}; + DFA.State s341 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_344 = input.LA(1); - if ( (LA16_344>='0' && LA16_344<='9')||(LA16_344>='A' && LA16_344<='Z')||LA16_344=='_'||(LA16_344>='a' && LA16_344<='z')||(LA16_344>='\u00C0' && LA16_344<='\u00FF') ) {return s51;} - return s354; + int LA16_341 = input.LA(1); + if ( (LA16_341>='0' && LA16_341<='9')||(LA16_341>='A' && LA16_341<='Z')||LA16_341=='_'||(LA16_341>='a' && LA16_341<='z')||(LA16_341>='\u00C0' && LA16_341<='\u00FF') ) {return s50;} + return s353; } }; - DFA.State s270 = new DFA.State() { + DFA.State s267 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_270 = input.LA(1); - if ( LA16_270=='e' ) {return s344;} - return s51; + int LA16_267 = input.LA(1); + if ( LA16_267=='e' ) {return s341;} + return s50; } }; - DFA.State s184 = new DFA.State() { + DFA.State s181 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_184 = input.LA(1); - if ( LA16_184=='s' ) {return s270;} - return s51; + int LA16_181 = input.LA(1); + if ( LA16_181=='s' ) {return s267;} + return s50; } }; - DFA.State s70 = new DFA.State() { + DFA.State s69 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_70 = input.LA(1); - if ( LA16_70=='l' ) {return s184;} - return s51; + int LA16_69 = input.LA(1); + if ( LA16_69=='l' ) {return s181;} + return s50; } }; @@ -3462,136 +3462,170 @@ public DFA.State transition(IntStream input) throws RecognitionException { switch ( input.LA(1) ) { case 'u': - return s69; + return s68; case 'a': - return s70; + return s69; default: - return s51; + return s50; } } }; - DFA.State s73 = new DFA.State() {{alt=9;}}; + DFA.State s72 = new DFA.State() {{alt=9;}}; DFA.State s8 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { int LA16_8 = input.LA(1); - return s73; + return s72; } }; - DFA.State s74 = new DFA.State() {{alt=10;}}; + DFA.State s73 = new DFA.State() {{alt=10;}}; DFA.State s9 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { int LA16_9 = input.LA(1); - return s74; + return s73; } }; - DFA.State s75 = new DFA.State() {{alt=11;}}; + DFA.State s74 = new DFA.State() {{alt=11;}}; DFA.State s10 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { int LA16_10 = input.LA(1); - return s75; + return s74; } }; - DFA.State s76 = new DFA.State() {{alt=12;}}; + DFA.State s75 = new DFA.State() {{alt=12;}}; DFA.State s11 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { int LA16_11 = input.LA(1); - return s76; + return s75; } }; - DFA.State s77 = new DFA.State() {{alt=13;}}; + DFA.State s76 = new DFA.State() {{alt=13;}}; DFA.State s12 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { int LA16_12 = input.LA(1); - return s77; + return s76; } }; DFA.State s404 = new DFA.State() {{alt=14;}}; - DFA.State s347 = new DFA.State() { + DFA.State s344 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_347 = input.LA(1); - if ( (LA16_347>='0' && LA16_347<='9')||(LA16_347>='A' && LA16_347<='Z')||LA16_347=='_'||(LA16_347>='a' && LA16_347<='z')||(LA16_347>='\u00C0' && LA16_347<='\u00FF') ) {return s51;} + int LA16_344 = input.LA(1); + if ( (LA16_344>='0' && LA16_344<='9')||(LA16_344>='A' && LA16_344<='Z')||LA16_344=='_'||(LA16_344>='a' && LA16_344<='z')||(LA16_344>='\u00C0' && LA16_344<='\u00FF') ) {return s50;} return s404; } }; + DFA.State s270 = new DFA.State() { + public DFA.State transition(IntStream input) throws RecognitionException { + int LA16_270 = input.LA(1); + if ( LA16_270=='y' ) {return s344;} + return s50; + + } + }; + DFA.State s184 = new DFA.State() { + public DFA.State transition(IntStream input) throws RecognitionException { + int LA16_184 = input.LA(1); + if ( LA16_184=='r' ) {return s270;} + return s50; + + } + }; + DFA.State s77 = new DFA.State() { + public DFA.State transition(IntStream input) throws RecognitionException { + int LA16_77 = input.LA(1); + if ( LA16_77=='e' ) {return s184;} + return s50; + + } + }; + DFA.State s13 = new DFA.State() { + public DFA.State transition(IntStream input) throws RecognitionException { + int LA16_13 = input.LA(1); + if ( LA16_13=='u' ) {return s77;} + return s50; + + } + }; + DFA.State s347 = new DFA.State() {{alt=16;}}; DFA.State s273 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { int LA16_273 = input.LA(1); - if ( LA16_273=='y' ) {return s347;} - return s51; + if ( (LA16_273>='0' && LA16_273<='9')||(LA16_273>='A' && LA16_273<='Z')||LA16_273=='_'||(LA16_273>='a' && LA16_273<='z')||(LA16_273>='\u00C0' && LA16_273<='\u00FF') ) {return s50;} + return s347; } }; DFA.State s187 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { int LA16_187 = input.LA(1); - if ( LA16_187=='r' ) {return s273;} - return s51; + if ( LA16_187=='e' ) {return s273;} + return s50; } }; - DFA.State s78 = new DFA.State() { + DFA.State s80 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_78 = input.LA(1); - if ( LA16_78=='e' ) {return s187;} - return s51; + int LA16_80 = input.LA(1); + if ( LA16_80=='l' ) {return s187;} + return s50; } }; - DFA.State s13 = new DFA.State() { + DFA.State s14 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_13 = input.LA(1); - if ( LA16_13=='u' ) {return s78;} - return s51; + int LA16_14 = input.LA(1); + if ( LA16_14=='u' ) {return s80;} + return s50; } }; - DFA.State s350 = new DFA.State() {{alt=16;}}; + DFA.State s349 = new DFA.State() {{alt=17;}}; DFA.State s276 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { int LA16_276 = input.LA(1); - if ( (LA16_276>='0' && LA16_276<='9')||(LA16_276>='A' && LA16_276<='Z')||LA16_276=='_'||(LA16_276>='a' && LA16_276<='z')||(LA16_276>='\u00C0' && LA16_276<='\u00FF') ) {return s51;} - return s350; + if ( (LA16_276>='0' && LA16_276<='9')||(LA16_276>='A' && LA16_276<='Z')||LA16_276=='_'||(LA16_276>='a' && LA16_276<='z')||(LA16_276>='\u00C0' && LA16_276<='\u00FF') ) {return s50;} + return s349; } }; DFA.State s190 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { int LA16_190 = input.LA(1); - if ( LA16_190=='e' ) {return s276;} - return s51; + if ( LA16_190=='n' ) {return s276;} + return s50; } }; - DFA.State s81 = new DFA.State() { + DFA.State s83 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_81 = input.LA(1); - if ( LA16_81=='l' ) {return s190;} - return s51; + int LA16_83 = input.LA(1); + if ( LA16_83=='e' ) {return s190;} + return s50; } }; - DFA.State s14 = new DFA.State() { + DFA.State s15 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_14 = input.LA(1); - if ( LA16_14=='u' ) {return s81;} - return s51; + int LA16_15 = input.LA(1); + if ( LA16_15=='h' ) {return s83;} + return s50; } }; - DFA.State s352 = new DFA.State() {{alt=17;}}; + DFA.State s16 = new DFA.State() {{alt=18;}}; + DFA.State s351 = new DFA.State() {{alt=19;}}; DFA.State s279 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { int LA16_279 = input.LA(1); - if ( (LA16_279>='0' && LA16_279<='9')||(LA16_279>='A' && LA16_279<='Z')||LA16_279=='_'||(LA16_279>='a' && LA16_279<='z')||(LA16_279>='\u00C0' && LA16_279<='\u00FF') ) {return s51;} - return s352; + if ( (LA16_279>='0' && LA16_279<='9')||(LA16_279>='A' && LA16_279<='Z')||LA16_279=='_'||(LA16_279>='a' && LA16_279<='z')||(LA16_279>='\u00C0' && LA16_279<='\u00FF') ) {return s50;} + return s351; } }; @@ -3599,32 +3633,23 @@ public DFA.State transition(IntStream input) throws RecognitionException { int LA16_193 = input.LA(1); if ( LA16_193=='n' ) {return s279;} - return s51; + return s50; } }; - DFA.State s84 = new DFA.State() { + DFA.State s86 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_84 = input.LA(1); - if ( LA16_84=='e' ) {return s193;} - return s51; + int LA16_86 = input.LA(1); + if ( LA16_86=='e' ) {return s193;} + return s50; } }; - DFA.State s15 = new DFA.State() { - public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_15 = input.LA(1); - if ( LA16_15=='h' ) {return s84;} - return s51; - - } - }; - DFA.State s16 = new DFA.State() {{alt=18;}}; DFA.State s282 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { int LA16_282 = input.LA(1); - if ( (LA16_282>='0' && LA16_282<='9')||(LA16_282>='A' && LA16_282<='Z')||LA16_282=='_'||(LA16_282>='a' && LA16_282<='z')||(LA16_282>='\u00C0' && LA16_282<='\u00FF') ) {return s51;} - return s354; + if ( (LA16_282>='0' && LA16_282<='9')||(LA16_282>='A' && LA16_282<='Z')||LA16_282=='_'||(LA16_282>='a' && LA16_282<='z')||(LA16_282>='\u00C0' && LA16_282<='\u00FF') ) {return s50;} + return s353; } }; @@ -3632,7 +3657,7 @@ public DFA.State transition(IntStream input) throws RecognitionException { int LA16_196 = input.LA(1); if ( LA16_196=='e' ) {return s282;} - return s51; + return s50; } }; @@ -3640,16 +3665,46 @@ public DFA.State transition(IntStream input) throws RecognitionException { int LA16_87 = input.LA(1); if ( LA16_87=='u' ) {return s196;} - return s51; + return s50; } }; - DFA.State s356 = new DFA.State() {{alt=19;}}; + DFA.State s17 = new DFA.State() { + public DFA.State transition(IntStream input) throws RecognitionException { + switch ( input.LA(1) ) { + case 'h': + return s86; + + case 'r': + return s87; + + default: + return s50; + } + } + }; + DFA.State s445 = new DFA.State() {{alt=25;}}; + DFA.State s406 = new DFA.State() { + public DFA.State transition(IntStream input) throws RecognitionException { + int LA16_406 = input.LA(1); + if ( LA16_406=='-' ) {return s445;} + return s50; + + } + }; + DFA.State s355 = new DFA.State() { + public DFA.State transition(IntStream input) throws RecognitionException { + int LA16_355 = input.LA(1); + if ( LA16_355=='a' ) {return s406;} + return s50; + + } + }; DFA.State s285 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { int LA16_285 = input.LA(1); - if ( (LA16_285>='0' && LA16_285<='9')||(LA16_285>='A' && LA16_285<='Z')||LA16_285=='_'||(LA16_285>='a' && LA16_285<='z')||(LA16_285>='\u00C0' && LA16_285<='\u00FF') ) {return s51;} - return s356; + if ( LA16_285=='d' ) {return s355;} + return s50; } }; @@ -3657,177 +3712,195 @@ public DFA.State transition(IntStream input) throws RecognitionException { int LA16_199 = input.LA(1); if ( LA16_199=='n' ) {return s285;} - return s51; + return s50; } }; - DFA.State s88 = new DFA.State() { + DFA.State s90 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_88 = input.LA(1); - if ( LA16_88=='e' ) {return s199;} - return s51; + int LA16_90 = input.LA(1); + if ( LA16_90=='e' ) {return s199;} + return s50; } }; - DFA.State s17 = new DFA.State() { + DFA.State s518 = new DFA.State() {{alt=24;}}; + DFA.State s512 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - switch ( input.LA(1) ) { - case 'r': - return s87; + int LA16_512 = input.LA(1); + if ( LA16_512=='-' ) {return s518;} + return s50; - case 'h': - return s88; + } + }; + DFA.State s500 = new DFA.State() { + public DFA.State transition(IntStream input) throws RecognitionException { + int LA16_500 = input.LA(1); + if ( LA16_500=='n' ) {return s512;} + return s50; - default: - return s51; - } } }; - DFA.State s288 = new DFA.State() {{alt=40;}}; - DFA.State s202 = new DFA.State() { + DFA.State s477 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_202 = input.LA(1); - if ( (LA16_202>='0' && LA16_202<='9')||(LA16_202>='A' && LA16_202<='Z')||LA16_202=='_'||(LA16_202>='a' && LA16_202<='z')||(LA16_202>='\u00C0' && LA16_202<='\u00FF') ) {return s51;} - return s288; + int LA16_477 = input.LA(1); + if ( LA16_477=='o' ) {return s500;} + return s50; } }; - DFA.State s91 = new DFA.State() { + DFA.State s448 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_91 = input.LA(1); - if ( LA16_91=='d' ) {return s202;} - return s51; + int LA16_448 = input.LA(1); + if ( LA16_448=='i' ) {return s477;} + return s50; } }; - DFA.State s442 = new DFA.State() {{alt=25;}}; - DFA.State s406 = new DFA.State() { + DFA.State s409 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_406 = input.LA(1); - if ( LA16_406=='-' ) {return s442;} - return s51; + int LA16_409 = input.LA(1); + if ( LA16_409=='t' ) {return s448;} + return s50; } }; DFA.State s358 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { int LA16_358 = input.LA(1); - if ( LA16_358=='a' ) {return s406;} - return s51; + if ( LA16_358=='a' ) {return s409;} + return s50; } }; - DFA.State s290 = new DFA.State() { + DFA.State s288 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { - int LA16_290 = input.LA(1); - if ( LA16_290=='d' ) {return s358;} - return s51; + int LA16_288 = input.LA(1); + if ( LA16_288=='v' ) {return s358;} + return s50; } }; + DFA.State s202 = new DFA.State() { + public DFA.State transition(IntStream input) throws RecognitionException { + int LA16_202 = input.LA(1); + if ( LA16_202=='i' ) {return s288;} + return s50; + + } + }; + DFA.State s91 = new DFA.State() { + public DFA.State transition(IntStream input) throws RecognitionException { + int LA16_91 = input.LA(1); + if ( LA16_91=='t' ) {return s202;} + return s50; + + } + }; + DFA.State s291 = new DFA.State() {{alt=40;}}; DFA.State s205 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { int LA16_205 = input.LA(1); - if ( LA16_205=='n' ) {return s290;} - return s51; + if ( (LA16_205>='0' && LA16_205<='9')||(LA16_205>='A' && LA16_205<='Z')||LA16_205=='_'||(LA16_205>='a' && LA16_205<='z')||(LA16_205>='\u00C0' && LA16_205<='\u00FF') ) {return s50;} + return s291; } }; DFA.State s92 = new DFA.State() { public DFA.State transition(IntStream input) throws RecognitionException { int LA16_92 = input.LA(1); - if ( LA16_92=='e' ) {return s205;} - return s51; + if ( LA16_92=='d' ) {... [truncated message content] |
From: <jbo...@li...> - 2006-05-15 11:29:59
|
Author: mar...@jb... Date: 2006-05-15 07:29:49 -0400 (Mon, 15 May 2006) New Revision: 4225 Added: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_ActivationGroups.drl Removed: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_XorGroups.drl Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/semantics/java/RuleBuilder.java labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/lang/drl.g labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/compiler/PackageBuilderTest.java labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/LeapsTest.java labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/lang/RuleParserTest.java labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/lang/rule_attributes.drl labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/lang/rule_attributes_alt.drl Log: -Change xor-group to activation-group Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/semantics/java/RuleBuilder.java =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/semantics/java/RuleBuilder.java 2006-05-15 11:29:45 UTC (rev 4224) +++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/semantics/java/RuleBuilder.java 2006-05-15 11:29:49 UTC (rev 4225) @@ -200,7 +200,7 @@ } } else if ( name.equals( "agenda-group" ) ) { rule.setAgendaGroup( attributeDescr.getValue() ); - } else if ( name.equals( "xor-group" ) ) { + } else if ( name.equals( "activation-group" ) ) { rule.setXorGroup( attributeDescr.getValue() ); } else if ( name.equals( "duration" ) ) { rule.setDuration( Long.parseLong( attributeDescr.getValue() ) ); Modified: labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/lang/drl.g =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/lang/drl.g 2006-05-15 11:29:45 UTC (rev 4224) +++ labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/lang/drl.g 2006-05-15 11:29:49 UTC (rev 4225) @@ -461,7 +461,7 @@ | a=no_loop { d = a; } | a=agenda_group { d = a; } | a=duration { d = a; } - | a=xor_group { d = a; } + | a=activation_group { d = a; } | a=auto_focus { d = a; } ; @@ -526,14 +526,14 @@ ; -xor_group returns [AttributeDescr d] +activation_group returns [AttributeDescr d] @init { d = null; } : - loc='xor-group' opt_eol name=STRING ';'? opt_eol + loc='activation-group' opt_eol name=STRING ';'? opt_eol { - d = new AttributeDescr( "xor-group", getString( name ) ); + d = new AttributeDescr( "activation-group", getString( name ) ); d.setLocation( offset(loc.getLine()), loc.getCharPositionInLine() ); } ; Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/compiler/PackageBuilderTest.java =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/compiler/PackageBuilderTest.java 2006-05-15 11:29:45 UTC (rev 4224) +++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/compiler/PackageBuilderTest.java 2006-05-15 11:29:49 UTC (rev 4225) @@ -37,7 +37,7 @@ import org.drools.WorkingMemory; import org.drools.common.InternalFactHandle; import org.drools.common.LogicalDependency; -import org.drools.common.XorGroupNode; +import org.drools.common.ActivationGroupNode; import org.drools.compiler.PackageBuilder; import org.drools.lang.descr.AndDescr; import org.drools.lang.descr.ColumnDescr; @@ -897,12 +897,12 @@ public void setActivated(boolean activated) { } - public XorGroupNode getXorGroupNode() { + public ActivationGroupNode getActivationGroupNode() { // TODO Auto-generated method stub return null; } - public void setXorGroupNode(XorGroupNode xorGroupNode) { + public void setActivationGroupNode(ActivationGroupNode activationGroupNode) { // TODO Auto-generated method stub } Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java 2006-05-15 11:29:45 UTC (rev 4224) +++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java 2006-05-15 11:29:49 UTC (rev 4225) @@ -59,7 +59,7 @@ import org.drools.rule.Package; import org.drools.rule.Rule; import org.drools.spi.AgendaGroup; -import org.drools.spi.XorGroup; +import org.drools.spi.ActivationGroup; /** * This contains the test cases for each engines implementation to execute. @@ -1162,13 +1162,13 @@ 12 ); workingMemory.assertObject( brie ); - XorGroup xorGroup0 = workingMemory.getAgenda().getXorGroup( "xor-group-0" ); + ActivationGroup activationGroup0 = workingMemory.getAgenda().getActivationGroup( "activation-group-0" ); assertEquals( 2, - xorGroup0.size() ); + activationGroup0.size() ); - XorGroup xorGroup3 = workingMemory.getAgenda().getXorGroup( "xor-group-3" ); + ActivationGroup activationGroup3 = workingMemory.getAgenda().getActivationGroup( "activation-group-3" ); assertEquals( 1, - xorGroup3.size() ); + activationGroup3.size() ); AgendaGroup agendaGroup3 = workingMemory.getAgenda().getAgendaGroup( "agenda-group-3" ); assertEquals( 1, @@ -1180,14 +1180,14 @@ workingMemory.clearAgendaGroup( "agenda-group-3" ); assertEquals( 0, - xorGroup3.size() ); + activationGroup3.size() ); assertEquals( 0, agendaGroup3.size() ); workingMemory.fireAllRules(); assertEquals( 0, - xorGroup0.size() ); + activationGroup0.size() ); assertEquals( 2, list.size() ); Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/LeapsTest.java =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/LeapsTest.java 2006-05-15 11:29:45 UTC (rev 4224) +++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/LeapsTest.java 2006-05-15 11:29:49 UTC (rev 4225) @@ -28,7 +28,7 @@ import org.drools.compiler.PackageBuilder; import org.drools.rule.Package; import org.drools.spi.AgendaGroup; -import org.drools.spi.XorGroup; +import org.drools.spi.ActivationGroup; /** * This runs the integration test cases with the leaps implementation. @@ -132,11 +132,11 @@ // while Xor group behaviour is supported by leaps certain functionality is no // due to the lazy nature of leaps and the fact that it does not accumulate - // activations before firing them we can not do counts on xor groups and + // activations before firing them we can not do counts on activation groups and // agenda groups as in base integration test public void testXorGroups() throws Exception { PackageBuilder builder = new PackageBuilder(); - builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_XorGroups.drl" ) ) ); + builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_ActivationGroups.drl" ) ) ); Package pkg = builder.getPackage(); RuleBase ruleBase = getRuleBase(); Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/lang/RuleParserTest.java =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/lang/RuleParserTest.java 2006-05-15 11:29:45 UTC (rev 4224) +++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/lang/RuleParserTest.java 2006-05-15 11:29:49 UTC (rev 4225) @@ -1261,8 +1261,8 @@ assertEquals("42", at.getValue()); at = (AttributeDescr) attrs.get( 4 ); - assertEquals("xor-group", at.getName()); - assertEquals("my_xor_group", at.getValue()); + assertEquals("activation-group", at.getName()); + assertEquals("my_activation_group", at.getValue()); assertFalse( parser.hasErrors() ); } @@ -1292,8 +1292,8 @@ assertEquals("42", at.getValue()); at = (AttributeDescr) attrs.get( 4 ); - assertEquals("xor-group", at.getName()); - assertEquals("my_xor_group", at.getValue()); + assertEquals("activation-group", at.getName()); + assertEquals("my_activation_group", at.getValue()); assertFalse( parser.hasErrors() ); } Copied: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_ActivationGroups.drl (from rev 4217, labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_XorGroups.drl) =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_XorGroups.drl 2006-05-14 23:24:48 UTC (rev 4217) +++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_ActivationGroups.drl 2006-05-15 11:29:49 UTC (rev 4225) @@ -0,0 +1,38 @@ +package org.drools.test; + +import org.drools.Cheese; + +global java.util.List list; + +rule "rule0" + salience 10 + activation-group "activation-group-0" + when + Cheese( ) + then + list.add( "rule0" ); +end + +rule "rule1" + activation-group "activation-group-0" + when + Cheese( ) + then + list.add( "rule1" ); +end + +rule "rul2" + when + Cheese( ) + then + list.add( "rule2" ); +end + +rule "rule3" + agenda-group "agenda-group-3" + activation-group "activatino-group-3" + when + Cheese( ) + then + list.add( "rule3" ); +end Deleted: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_XorGroups.drl =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_XorGroups.drl 2006-05-15 11:29:45 UTC (rev 4224) +++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_XorGroups.drl 2006-05-15 11:29:49 UTC (rev 4225) @@ -1,38 +0,0 @@ -package org.drools.test; - -import org.drools.Cheese; - -global java.util.List list; - -rule "rule0" - salience 10 - xor-group "xor-group-0" - when - Cheese( ) - then - list.add( "rule0" ); -end - -rule "rule1" - xor-group "xor-group-0" - when - Cheese( ) - then - list.add( "rule1" ); -end - -rule "rul2" - when - Cheese( ) - then - list.add( "rule2" ); -end - -rule "rule3" - agenda-group "agenda-group-3" - xor-group "xor-group-3" - when - Cheese( ) - then - list.add( "rule3" ); -end Modified: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/lang/rule_attributes.drl =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/lang/rule_attributes.drl 2006-05-15 11:29:45 UTC (rev 4224) +++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/lang/rule_attributes.drl 2006-05-15 11:29:49 UTC (rev 4225) @@ -7,7 +7,7 @@ agenda-group "my_group" no-loop duration 42 - xor-group "my_xor_group" + activation-group "my_activation_group" when Foo() then Modified: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/lang/rule_attributes_alt.drl =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/lang/rule_attributes_alt.drl 2006-05-15 11:29:45 UTC (rev 4224) +++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/lang/rule_attributes_alt.drl 2006-05-15 11:29:49 UTC (rev 4225) @@ -3,7 +3,7 @@ rule simple_rule attributes: - salience 42, agenda-group "my_group", no-loop, duration 42, xor-group "my_xor_group" + salience 42, agenda-group "my_group", no-loop, duration 42, activation-group "my_activation_group" when Foo() then |
From: <jbo...@li...> - 2006-05-15 11:29:53
|
Author: mar...@jb... Date: 2006-05-15 07:29:45 -0400 (Mon, 15 May 2006) New Revision: 4224 Modified: labs/jbossrules/trunk/drools-ide/src/main/java/org/drools/ide/editors/completion/RuleCompletionProcessor.java labs/jbossrules/trunk/drools-ide/src/main/java/org/drools/ide/editors/keywords.properties Log: -Change xor-group to activation-group Modified: labs/jbossrules/trunk/drools-ide/src/main/java/org/drools/ide/editors/completion/RuleCompletionProcessor.java =================================================================== --- labs/jbossrules/trunk/drools-ide/src/main/java/org/drools/ide/editors/completion/RuleCompletionProcessor.java 2006-05-15 11:26:23 UTC (rev 4223) +++ labs/jbossrules/trunk/drools-ide/src/main/java/org/drools/ide/editors/completion/RuleCompletionProcessor.java 2006-05-15 11:29:45 UTC (rev 4224) @@ -170,7 +170,7 @@ list.add(new RuleCompletionProposal(prefix.length(), "duration", "duration ", droolsIcon)); list.add(new RuleCompletionProposal(prefix.length(), "auto-focus", "auto-focus ", droolsIcon)); list.add(new RuleCompletionProposal(prefix.length(), "when", "when\n\t ", droolsIcon)); - list.add(new RuleCompletionProposal(prefix.length(), "xor-group", "xor-group ", droolsIcon)); + list.add(new RuleCompletionProposal(prefix.length(), "activation-group", "activation-group ", droolsIcon)); } private void addDSLProposals(final List list, Modified: labs/jbossrules/trunk/drools-ide/src/main/java/org/drools/ide/editors/keywords.properties =================================================================== --- labs/jbossrules/trunk/drools-ide/src/main/java/org/drools/ide/editors/keywords.properties 2006-05-15 11:26:23 UTC (rev 4223) +++ labs/jbossrules/trunk/drools-ide/src/main/java/org/drools/ide/editors/keywords.properties 2006-05-15 11:29:45 UTC (rev 4224) @@ -22,5 +22,5 @@ -> not auto-focus -xor-group +activation-group new |
From: <jbo...@li...> - 2006-05-15 11:26:31
|
Author: mar...@jb... Date: 2006-05-15 07:26:23 -0400 (Mon, 15 May 2006) New Revision: 4223 Modified: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Rule.java labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/ActionType.java labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/RuleSheetListener.java Log: -Change xor-group to activation-group Modified: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Rule.java =================================================================== --- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Rule.java 2006-05-15 11:26:12 UTC (rev 4222) +++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Rule.java 2006-05-15 11:26:23 UTC (rev 4223) @@ -47,8 +47,8 @@ private String _noLoop; // RIK: New variable to the Rule class (Set the // no-loop parameter of the rule tag) - private String _xorGroup; // RIK: New variable to the Rule class (Set the - // xor-group parameter of the rule tag) + private String _activationGroup; // RIK: New variable to the Rule class (Set the + // activation-group parameter of the rule tag) private List _lhs; @@ -88,7 +88,7 @@ out.writeLine("rule " + "\"" + _name + "\""); if (_description != null) out.writeLine("\t" + _description); if (_salience != null) out.writeLine("\tsalience " + _salience); - if (_xorGroup != null) out.writeLine("\txor-group" + _xorGroup); + if (_activationGroup != null) out.writeLine("\tactivation-group" + _activationGroup); if (_noLoop != null) out.writeLine("\tno-loop" + _noLoop); if (_duration != null) out.writeLine("\tduration" + _duration); @@ -205,13 +205,13 @@ return _duration.getSnippet(); } - public void setXorGroup(String value) // Set the duration of the rule + public void setActivationrGroup(String value) // Set the duration of the rule { - _xorGroup = value; + _activationGroup = value; } - public String getXorGroup() { - return _xorGroup; + public String getActivationGroup() { + return _activationGroup; } public void setNoLoop(String value) // Set the no-loop attribute of the rule Modified: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/ActionType.java =================================================================== --- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/ActionType.java 2006-05-15 11:26:12 UTC (rev 4222) +++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/ActionType.java 2006-05-15 11:26:23 UTC (rev 4223) @@ -56,8 +56,8 @@ // NOLOOP is used to set the no-loop parameter of a rule tag public static final int NOLOOP = 6; - // XOR-GROUP is used to set the xor-group parameter of a rule tag - public static final int XORGROUP = 7; + // XOR-GROUP is used to set the activation-group parameter of a rule tag + public static final int ACTIVATIONGROUP = 7; int type; @@ -160,7 +160,7 @@ // list { actionTypeMap.put( new Integer( column ), - new ActionType( ActionType.XORGROUP, + new ActionType( ActionType.ACTIVATIONGROUP, null ) ); } else Modified: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/RuleSheetListener.java =================================================================== --- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/RuleSheetListener.java 2006-05-15 11:26:12 UTC (rev 4222) +++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/RuleSheetListener.java 2006-05-15 11:26:23 UTC (rev 4223) @@ -364,7 +364,7 @@ // from the cell { _currentRule.setDescription( value ); - } else if ( actionType.type == ActionType.XORGROUP ) // if the actionType + } else if ( actionType.type == ActionType.ACTIVATIONGROUP ) // if the actionType // type is NOLOOP // then set the // current Rule's @@ -373,7 +373,7 @@ // the value got // from the cell { - _currentRule.setXorGroup( value ); + _currentRule.setActivationrGroup( value ); } else if ( actionType.type == ActionType.NOLOOP ) // if the actionType // type is NOLOOP // then set the |
Author: mar...@jb... Date: 2006-05-15 07:26:12 -0400 (Mon, 15 May 2006) New Revision: 4222 Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/ActivationGroupImpl.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/ActivationGroupNode.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/ActivationGroup.java Removed: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/XorGroupImpl.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/XorGroupNode.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/XorGroup.java Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/Agenda.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AgendaItem.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/ScheduledAgendaItem.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsAgenda.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/TerminalNode.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Rule.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/Activation.java labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/AgendaTest.java Log: -Change xor-group to activation-group Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/ActivationGroupImpl.java (from rev 4217, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/XorGroupImpl.java) =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/XorGroupImpl.java 2006-05-14 23:24:48 UTC (rev 4217) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/ActivationGroupImpl.java 2006-05-15 11:26:12 UTC (rev 4222) @@ -0,0 +1,52 @@ +package org.drools.common; + +import java.util.Iterator; + +import org.drools.spi.Activation; +import org.drools.spi.ActivationGroup; +import org.drools.util.LinkedList; +import org.drools.util.LinkedListObjectWrapper; + +public class ActivationGroupImpl implements ActivationGroup { + private String name; + + private final LinkedList list; + + public ActivationGroupImpl(String name) { + this.name = name; + this.list = new LinkedList(); + } + + public String getName() { + return this.name; + } + + public void addActivation(Activation activation) { + ActivationGroupNode node = new ActivationGroupNode(activation, this); + activation.setActivationGroupNode( node ); + this.list.add( node ); + } + + public void removeActivation(Activation activation) { + ActivationGroupNode node = activation.getActivationGroupNode( ); + this.list.remove( node ); + activation.setActivationGroupNode( null ); + } + + public Iterator iterator() { + return this.list.iterator(); + } + + public boolean isEmpty() { + return this.list.isEmpty(); + } + + public int size() { + return this.list.size(); + } + + public void clear() { + this.list.clear(); + } + +} Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/ActivationGroupNode.java (from rev 4217, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/XorGroupNode.java) =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/XorGroupNode.java 2006-05-14 23:24:48 UTC (rev 4217) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/ActivationGroupNode.java 2006-05-15 11:26:12 UTC (rev 4222) @@ -0,0 +1,30 @@ +package org.drools.common; + +import org.drools.spi.Activation; +import org.drools.spi.ActivationGroup; +import org.drools.util.AbstractBaseLinkedListNode; + +public class ActivationGroupNode extends AbstractBaseLinkedListNode { + + private Activation activation; + + private ActivationGroup activationGroup; + + public ActivationGroupNode(Activation activation, + ActivationGroup activationGroup) { + super(); + this.activation = activation; + this.activationGroup = activationGroup; + } + + public Activation getActivation() { + return this.activation; + } + + public ActivationGroup getActivationGroup() { + return this.activationGroup; + } + + + +} Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/Agenda.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/Agenda.java 2006-05-15 07:35:06 UTC (rev 4221) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/Agenda.java 2006-05-15 11:26:12 UTC (rev 4222) @@ -31,7 +31,7 @@ import org.drools.spi.AgendaGroup; import org.drools.spi.ConsequenceException; import org.drools.spi.KnowledgeHelper; -import org.drools.spi.XorGroup; +import org.drools.spi.ActivationGroup; import org.drools.util.LinkedListNode; import org.drools.util.LinkedListObjectWrapper; import org.drools.util.Queueable; @@ -69,7 +69,7 @@ private final Map agendaGroups; - private final Map xorGroups; + private final Map activationGroups; private final LinkedList focusStack; @@ -92,7 +92,7 @@ public Agenda(WorkingMemory workingMemory) { this.workingMemory = workingMemory; this.agendaGroups = new HashMap(); - this.xorGroups = new HashMap(); + this.activationGroups = new HashMap(); this.focusStack = new LinkedList(); // MAIN should always be the first AgendaGroup and can never be removed @@ -208,13 +208,13 @@ return (AgendaGroup[]) this.focusStack.toArray( new AgendaGroup[this.focusStack.size()] ); } - public XorGroup getXorGroup(String name) { - XorGroupImpl xorGroup = (XorGroupImpl) this.xorGroups.get( name ); - if (xorGroup == null) { - xorGroup = new XorGroupImpl( name ); - this.xorGroups.put( name, xorGroup ); + public ActivationGroup getActivationGroup(String name) { + ActivationGroupImpl activationGroup = (ActivationGroupImpl) this.activationGroups.get( name ); + if (activationGroup == null) { + activationGroup = new ActivationGroupImpl( name ); + this.activationGroups.put( name, activationGroup ); } - return xorGroup; + return activationGroup; } /** @@ -314,8 +314,8 @@ // this must be set false before removal from the XorGroup. Otherwise the XorGroup will also try to cancel the Actvation item.setActivated( false ); - if ( item.getXorGroupNode() != null ) { - item.getXorGroupNode().getXorGroup().removeActivation( item ); + if ( item.getActivationGroupNode() != null ) { + item.getActivationGroupNode().getActivationGroup().removeActivation( item ); } eventsupport.getAgendaEventSupport().fireActivationCancelled( item ); @@ -325,15 +325,15 @@ /** - * Clears all Activations from an Xor Group. Any Activations that are also in an Agenda Group are removed + * Clears all Activations from an Activation-Group. Any Activations that are also in an Agenda Group are removed * from the Agenda Group. * - * @param xorGroup + * @param activationGroup */ - public void clearXorGroup(String name) { - XorGroup xorGroup = (XorGroup) this.xorGroups.get( name ); - if ( xorGroup != null ) { - clearXorGroup( xorGroup ); + public void clearActivationGroup(String name) { + ActivationGroup activationGroup = (ActivationGroup) this.activationGroups.get( name ); + if ( activationGroup != null ) { + clearActivationGroup( activationGroup ); } } @@ -341,13 +341,13 @@ * Clears all Activations from an Xor Group. Any Activations that are also in an Agenda Group are removed * from the Agenda Group. * - * @param xorGroup + * @param activationGroup */ - public void clearXorGroup(XorGroup xorGroup) { + public void clearActivationGroup(ActivationGroup activationGroup) { EventSupport eventsupport = (EventSupport) this.workingMemory; - for ( Iterator it = xorGroup.iterator(); it.hasNext(); ) { - Activation activation = ( Activation)( (XorGroupNode) it.next() ).getActivation(); - activation.setXorGroupNode( null ); + for ( Iterator it = activationGroup.iterator(); it.hasNext(); ) { + Activation activation = ( Activation)( (ActivationGroupNode) it.next() ).getActivation(); + activation.setActivationGroupNode( null ); if ( activation.isActivated() ) { activation.setActivated( false ); @@ -355,7 +355,7 @@ eventsupport.getAgendaEventSupport().fireActivationCancelled( activation ); } } - xorGroup.clear(); + activationGroup.clear(); } /** @@ -398,10 +398,10 @@ eventsupport.getAgendaEventSupport().fireBeforeActivationFired( activation ); - if ( activation.getXorGroupNode() != null ) { - XorGroup xorGroup = activation.getXorGroupNode().getXorGroup(); - xorGroup.removeActivation( activation ); - clearXorGroup(xorGroup); + if ( activation.getActivationGroupNode() != null ) { + ActivationGroup activationGroup = activation.getActivationGroupNode().getActivationGroup(); + activationGroup.removeActivation( activation ); + clearActivationGroup(activationGroup); } activation.setActivated( false ); Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AgendaItem.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AgendaItem.java 2006-05-15 07:35:06 UTC (rev 4221) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AgendaItem.java 2006-05-15 11:26:12 UTC (rev 4222) @@ -65,7 +65,7 @@ private boolean activated; - private XorGroupNode xorGroupNode; + private ActivationGroupNode activationGroupNode; // ------------------------------------------------------------ // Constructors @@ -204,11 +204,11 @@ dequeue(); } - public XorGroupNode getXorGroupNode() { - return this.xorGroupNode; + public ActivationGroupNode getActivationGroupNode() { + return this.activationGroupNode; } - public void setXorGroupNode(XorGroupNode xorNode) { - this.xorGroupNode = xorNode; - } + public void setActivationGroupNode(ActivationGroupNode activationNode) { + this.activationGroupNode = activationNode; + } } Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/ScheduledAgendaItem.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/ScheduledAgendaItem.java 2006-05-15 07:35:06 UTC (rev 4221) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/ScheduledAgendaItem.java 2006-05-15 11:26:12 UTC (rev 4222) @@ -24,7 +24,7 @@ import org.drools.spi.Activation; import org.drools.spi.PropagationContext; import org.drools.spi.Tuple; -import org.drools.spi.XorGroup; +import org.drools.spi.ActivationGroup; import org.drools.util.LinkedList; import org.drools.util.LinkedListNode; import org.drools.util.LinkedListObjectWrapper; @@ -63,7 +63,7 @@ private boolean activated; - private XorGroupNode xorGroupNode; + private ActivationGroupNode activationGroupNode; // ------------------------------------------------------------ // Constructors @@ -184,12 +184,12 @@ this.activated = activated; } - public XorGroupNode getXorGroupNode() { - return this.xorGroupNode; + public ActivationGroupNode getActivationGroupNode() { + return this.activationGroupNode; } - public void setXorGroupNode(XorGroupNode xorGroupNode) { - this.xorGroupNode = xorGroupNode; + public void setActivationGroupNode(ActivationGroupNode activationGroupNode) { + this.activationGroupNode = activationGroupNode; } /* Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/XorGroupImpl.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/XorGroupImpl.java 2006-05-15 07:35:06 UTC (rev 4221) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/XorGroupImpl.java 2006-05-15 11:26:12 UTC (rev 4222) @@ -1,52 +0,0 @@ -package org.drools.common; - -import java.util.Iterator; - -import org.drools.spi.Activation; -import org.drools.spi.XorGroup; -import org.drools.util.LinkedList; -import org.drools.util.LinkedListObjectWrapper; - -public class XorGroupImpl implements XorGroup { - private String name; - - private final LinkedList list; - - public XorGroupImpl(String name) { - this.name = name; - this.list = new LinkedList(); - } - - public String getName() { - return this.name; - } - - public void addActivation(Activation activation) { - XorGroupNode node = new XorGroupNode(activation, this); - activation.setXorGroupNode( node ); - this.list.add( node ); - } - - public void removeActivation(Activation activation) { - XorGroupNode node = activation.getXorGroupNode( ); - this.list.remove( node ); - activation.setXorGroupNode( null ); - } - - public Iterator iterator() { - return this.list.iterator(); - } - - public boolean isEmpty() { - return this.list.isEmpty(); - } - - public int size() { - return this.list.size(); - } - - public void clear() { - this.list.clear(); - } - -} Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/XorGroupNode.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/XorGroupNode.java 2006-05-15 07:35:06 UTC (rev 4221) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/XorGroupNode.java 2006-05-15 11:26:12 UTC (rev 4222) @@ -1,30 +0,0 @@ -package org.drools.common; - -import org.drools.spi.Activation; -import org.drools.spi.XorGroup; -import org.drools.util.AbstractBaseLinkedListNode; - -public class XorGroupNode extends AbstractBaseLinkedListNode { - - private Activation activation; - - private XorGroup xorGroup; - - public XorGroupNode(Activation activation, - XorGroup xorGroup) { - super(); - this.activation = activation; - this.xorGroup = xorGroup; - } - - public Activation getActivation() { - return this.activation; - } - - public XorGroup getXorGroup() { - return this.xorGroup; - } - - - -} Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsAgenda.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsAgenda.java 2006-05-15 07:35:06 UTC (rev 4221) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsAgenda.java 2006-05-15 11:26:12 UTC (rev 4222) @@ -47,14 +47,14 @@ activation.getTuple( ) ); } else { - if (activation.getRule( ).getXorGroup( ) == null - || ( activation.getRule( ).getXorGroup( ) != null && this.getXorGroup( activation.getRule( ) - .getXorGroup( ) ) + if (activation.getRule( ).getActivationGroup( ) == null + || ( activation.getRule( ).getActivationGroup( ) != null && this.getActivationGroup( activation.getRule( ) + .getActivationGroup( ) ) .isEmpty( ) )) { // fire regular rule super.fireActivation( activation ); - if (activation.getRule( ).getXorGroup( ) != null) { - this.getXorGroup( activation.getRule( ).getXorGroup( ) ); + if (activation.getRule( ).getActivationGroup( ) != null) { + this.getActivationGroup( activation.getRule( ).getActivationGroup( ) ); } } } Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/TerminalNode.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/TerminalNode.java 2006-05-15 07:35:06 UTC (rev 4221) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/TerminalNode.java 2006-05-15 11:26:12 UTC (rev 4222) @@ -30,7 +30,7 @@ import org.drools.spi.AgendaGroup; import org.drools.spi.Duration; import org.drools.spi.PropagationContext; -import org.drools.spi.XorGroup; +import org.drools.spi.ActivationGroup; import org.drools.util.LinkedListObjectWrapper; import org.drools.util.Queueable; @@ -132,13 +132,13 @@ context, this.rule ); - if ( this.rule.getXorGroup() != null ) { + if ( this.rule.getActivationGroup() != null ) { final TerminalNodeMemory memory = (TerminalNodeMemory) workingMemory.getNodeMemory( this ); - // Lazy cache xorGroup - if ( memory.getXorGroup() == null ) { - memory.setXorGroup( workingMemory.getAgenda().getXorGroup( this.rule.getXorGroup() ) ); + // Lazy cache activationGroup + if ( memory.getActivationGroup() == null ) { + memory.setActivationGroup( workingMemory.getAgenda().getActivationGroup( this.rule.getActivationGroup() ) ); } - memory.getXorGroup().addActivation( item ); + memory.getActivationGroup().addActivation( item ); } agenda.scheduleItem( item ); @@ -183,12 +183,12 @@ context, this.rule ); - if ( this.rule.getXorGroup() != null ) { - // Lazy cache xorGroup - if ( memory.getXorGroup() == null ) { - memory.setXorGroup( workingMemory.getAgenda().getXorGroup( this.rule.getXorGroup() ) ); + if ( this.rule.getActivationGroup() != null ) { + // Lazy cache activationGroup + if ( memory.getActivationGroup() == null ) { + memory.setActivationGroup( workingMemory.getAgenda().getActivationGroup( this.rule.getActivationGroup() ) ); } - memory.getXorGroup().addActivation( item ); + memory.getActivationGroup().addActivation( item ); } // Makes sure the Lifo is added to the AgendaGroup priority queue @@ -319,7 +319,7 @@ class TerminalNodeMemory { private AgendaGroupImpl agendaGroup; - private XorGroup xorGroup; + private ActivationGroup activationGroup; public AgendaGroupImpl getAgendaGroup() { return this.agendaGroup; @@ -329,12 +329,12 @@ this.agendaGroup = agendaGroup; } - public XorGroup getXorGroup() { - return this.xorGroup; + public ActivationGroup getActivationGroup() { + return this.activationGroup; } - public void setXorGroup(XorGroup xorGroup) { - this.xorGroup = xorGroup; + public void setActivationGroup(ActivationGroup activationGroup) { + this.activationGroup = activationGroup; } Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Rule.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Rule.java 2006-05-15 07:35:06 UTC (rev 4221) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Rule.java 2006-05-15 11:26:12 UTC (rev 4222) @@ -78,7 +78,7 @@ /** makes the rule's much the current focus */ private boolean autoFocus; - private String xorGroup; + private String ActivationGroup; /** indicates that the rule is semantically correct. */ private boolean semanticallyValid = true; @@ -245,12 +245,12 @@ this.autoFocus = autoFocus; } - public String getXorGroup() { - return this.xorGroup; + public String getActivationGroup() { + return this.ActivationGroup; } - public void setXorGroup(String xorGroup) { - this.xorGroup = xorGroup; + public void setXorGroup(String activationGroup) { + this.ActivationGroup = activationGroup; } /** @@ -427,7 +427,7 @@ Rule other = (Rule) object; - return (this.name.equals( other.name ) && this.agendaGroup.equals( other.agendaGroup ) && this.xorGroup.equals( other.xorGroup )&& this.salience == other.salience && this.noLoop == other.noLoop); + return (this.name.equals( other.name ) && this.agendaGroup.equals( other.agendaGroup ) && this.ActivationGroup.equals( other.ActivationGroup )&& this.salience == other.salience && this.noLoop == other.noLoop); } public int hashCode() { Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/Activation.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/Activation.java 2006-05-15 07:35:06 UTC (rev 4221) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/Activation.java 2006-05-15 11:26:12 UTC (rev 4222) @@ -20,7 +20,7 @@ import org.drools.common.LogicalDependency; -import org.drools.common.XorGroupNode; +import org.drools.common.ActivationGroupNode; import org.drools.rule.Rule; import org.drools.util.LinkedList; import org.drools.util.LinkedListObjectWrapper; @@ -76,7 +76,7 @@ public void setActivated(boolean activated); - public XorGroupNode getXorGroupNode(); + public ActivationGroupNode getActivationGroupNode(); - public void setXorGroupNode(XorGroupNode xorGroupNode); + public void setActivationGroupNode(ActivationGroupNode activationGroupNode); } \ No newline at end of file Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/ActivationGroup.java (from rev 4217, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/XorGroup.java) =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/XorGroup.java 2006-05-14 23:24:48 UTC (rev 4217) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/ActivationGroup.java 2006-05-15 11:26:12 UTC (rev 4222) @@ -0,0 +1,19 @@ +package org.drools.spi; + +import java.util.Iterator; + +public interface ActivationGroup { + public String getName(); + + public void addActivation(Activation activation); + + public void removeActivation(Activation activation); + + public Iterator iterator(); + + public boolean isEmpty(); + + public int size(); + + public void clear(); +} Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/XorGroup.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/XorGroup.java 2006-05-15 07:35:06 UTC (rev 4221) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/XorGroup.java 2006-05-15 11:26:12 UTC (rev 4222) @@ -1,19 +0,0 @@ -package org.drools.spi; - -import java.util.Iterator; - -public interface XorGroup { - public String getName(); - - public void addActivation(Activation activation); - - public void removeActivation(Activation activation); - - public Iterator iterator(); - - public boolean isEmpty(); - - public int size(); - - public void clear(); -} Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/AgendaTest.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/AgendaTest.java 2006-05-15 07:35:06 UTC (rev 4221) +++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/AgendaTest.java 2006-05-15 11:26:12 UTC (rev 4222) @@ -35,7 +35,7 @@ import org.drools.spi.ConsequenceException; import org.drools.spi.KnowledgeHelper; import org.drools.spi.PropagationContext; -import org.drools.spi.XorGroup; +import org.drools.spi.ActivationGroup; /** * @author mproctor @@ -482,7 +482,7 @@ // create a rule for each agendaGroup Rule rule0 = new Rule( "test-rule0" ); - rule0.setXorGroup( "xor-group-0" ); + rule0.setXorGroup( "activation-group-0" ); TerminalNode node0 = new TerminalNode( 3, new MockTupleSource( 2 ), rule0 ); @@ -493,7 +493,7 @@ null ); Rule rule1 = new Rule( "test-rule1" ); - rule1.setXorGroup( "xor-group-0" ); + rule1.setXorGroup( "activation-group-0" ); TerminalNode node1 = new TerminalNode( 5, new MockTupleSource( 4 ), rule1 ); @@ -515,7 +515,7 @@ Rule rule3 = new Rule( "test-rule3", "agendaGroup3" ); - rule3.setXorGroup( "xor-group-3" ); + rule3.setXorGroup( "activation-group-3" ); TerminalNode node3 = new TerminalNode( 9, new MockTupleSource( 8 ), rule3 ); @@ -525,23 +525,23 @@ rule3, null ); - // Assert the tuple and check it was added to xor-group-0 + // Assert the tuple and check it was added to activation-group-0 node0.assertTuple( tuple, context0, workingMemory ); - XorGroup xorGroup0 = agenda.getXorGroup( "xor-group-0" ); - assertEquals( 1, xorGroup0.size() ); + ActivationGroup activationGroup0 = agenda.getActivationGroup( "activation-group-0" ); + assertEquals( 1, activationGroup0.size() ); - // Assert another tuple and check it was added to xor-group-0 + // Assert another tuple and check it was added to activation-group-0 node1.assertTuple( tuple, context1, workingMemory ); - assertEquals( 2, xorGroup0.size() ); + assertEquals( 2, activationGroup0.size() ); // There should now be two potential activations to fire assertEquals( 2, agenda.focusStackSize() ); - // The first tuple should fire, adding itself to the List and clearing and cancelling the other Activations in the xor-group-0 + // The first tuple should fire, adding itself to the List and clearing and cancelling the other Activations in the activation-group-0 agenda.fireNextItem( null ); - // Make sure the xor-group-0 is clear - assertEquals( 0, xorGroup0.size() ); + // Make sure the activation-group-0 is clear + assertEquals( 0, activationGroup0.size() ); // Make sure the Agenda is empty assertEquals( 0, agenda.focusStackSize() ); @@ -559,23 +559,23 @@ node2.assertTuple( tuple, context2, workingMemory ); node3.assertTuple( tuple, context3, workingMemory ); - // xor-group-0 should be populated again - assertEquals( 2, xorGroup0.size() ); + // activation-group-0 should be populated again + assertEquals( 2, activationGroup0.size() ); - // make sure the xor-group-3 is cleared when we can clear the Agenda Group for the activation that is in both - XorGroup xorGroup3 = agenda.getXorGroup( "xor-group-3" ); + // make sure the activation-group-3 is cleared when we can clear the Agenda Group for the activation that is in both + ActivationGroup activationGroup3 = agenda.getActivationGroup( "activation-group-3" ); assertEquals( 4, agenda.agendaSize() ); - assertEquals( 1, xorGroup3.size() ); + assertEquals( 1, activationGroup3.size() ); agenda.clearAgendaGroup( "agendaGroup3" ); assertEquals( 3, agenda.agendaSize() ); - assertEquals( 0, xorGroup3.size() ); + assertEquals( 0, activationGroup3.size() ); - // Activation for xor-group-0 should be next - the activation in no xor/agenda group should remain on the agenda + // Activation for activation-group-0 should be next - the activation in no activation/agenda group should remain on the agenda agenda.fireNextItem( null ); assertEquals( 1, agenda.agendaSize() ); - assertEquals( 0, xorGroup0.size() ); + assertEquals( 0, activationGroup0.size() ); // Fire the last activation and make sure the Agenda Empties |
From: <jbo...@li...> - 2006-05-15 07:35:24
|
Author: mic...@jb... Date: 2006-05-15 03:35:06 -0400 (Mon, 15 May 2006) New Revision: 4221 Added: labs/jbossrules/trunk/documentation/manual/en/Chapter-Deployment/Section-Testing.xml labs/jbossrules/trunk/documentation/manual/en/Chapter-Deployment/Testing1.png labs/jbossrules/trunk/documentation/manual/en/Chapter-Deployment/Testing2.png Modified: labs/jbossrules/trunk/documentation/manual/en/Chapter-Rule_Engine/Section-Working_Memory.xml Log: stuff on logical assertions Added: labs/jbossrules/trunk/documentation/manual/en/Chapter-Deployment/Section-Testing.xml =================================================================== --- labs/jbossrules/trunk/documentation/manual/en/Chapter-Deployment/Section-Testing.xml 2006-05-15 06:50:07 UTC (rev 4220) +++ labs/jbossrules/trunk/documentation/manual/en/Chapter-Deployment/Section-Testing.xml 2006-05-15 07:35:06 UTC (rev 4221) @@ -0,0 +1,98 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE section PUBLIC "-//OASIS//DTD Simplified DocBook XML V1.0//EN" +"http://www.oasis-open.org/docbook/xml/simple/1.0/sdocbook.dtd"> +<section> + <title>Testing</title> + + <para>In recent years, practices such as Test Driven Development have become + increasingly mainstream, as the value and quality that these techniques + bring to software development has been realised. In a sense, rules are code + (although at a highlevel), and a lot of the same principles apply.</para> + + <para>You can provide tests as a means to specify rule behaviour before + rules are even written. Further to this, tests are even more important in + environments where rules change frequently. Tests can provide a baseline of + confidence that the rule changes are consistent with what is specified in + the tests. Of course, the rules may change in such a way as the tests are + now wrong (or perhaps new tests need to be written to cover the new rule + behaviour). As in TDD practices, tests should be run often, and in a rule + driven environment, this means that they should be run everytime the rules + change (even though the software may be static).</para> + + <section> + <title>Testing frameworks</title> + + <para>For developers, clearly JUnit (or TestNG) are popular tools for + testing code, and these can also apply to rules. Keep in mind that rule + changes may happen out of sync with code changes, so you should be + prepared to keep these unit tests up to date with rules (may not be + possible in all environments). Also, the best idea is to target testing + some core features of the rule sets that are not as likely to change over + time.</para> + + <para>Obviously, for rule tests, other non source code driven frameworks + would be preferable to test rules in some environments. The following + section outlines a rule testing component add on.</para> + </section> + + <section> + <title>FIT for Rules - a rule testing framework</title> + + <para>As a seperate add-on, there is a testing framework available that is + built on FIT (Framework for Integrated Testing). This allows rule test + suites (functional) to be capture in Word documents, or Excel spreadsheets + (in fact any tool that can save as HTML). It utilises a tabular layout to + capture input data, and make assertions over the rules of a rulesets + execution for the given facts. As the tests are stored in documents, the + scenarious and requirements can be (optionally) kept in the same + documents, providing a single point of truth for rule behaviour.</para> + + <para>Also, as the test documents are not code, they can be updated + frequently, and kept with the rules, used to validate rule changes etc. As + the input format is fairly simple to people familiar with the domain of + the rules, it also facilitates "scenario testing" where different + scenarious can be tried out with the rules - all external to the + application that the rules are used in. These scenarios can then be kept + as tests to increase confidence that a rule change is consistent with the + users understanding.</para> + + <para>This testing framework is built on FIT and JSR-94, and is kept as a + seperate project to JBoss Rules. Due to it being built on FIT, it requires + a different licence (but is still open source). You can download and read + more about this tool from this web page: <ulink + url="http://fit-for-rules.sourceforge.net/"> + <citetitle>Fit for rules</citetitle> + </ulink> http://fit-for-rules.sourceforge.net/</para> + + <para>The following screen captures show the fit for rules framework in + action.</para> + + <screenshot> + <mediaobject> + <imageobject> + <imagedata fileref="Testing1.png" /> + </imageobject> + </mediaobject> + </screenshot> + + <para>Using Fit for rules, you capture test data, pass it to the rule + engine and then verify the results (with documentation woven in with the + test). It is expected that in future, the Drools Server tools will provide + a similar integrated framework for testing (green means good ! red means a + failure - with the expected values placed in the cell). Refer to + http://fit.c2.com for more information on the FIT framework itself.</para> + + <screenshot> + <mediaobject> + <imageobject> + <imagedata fileref="Testing2.png" /> + </imageobject> + </mediaobject> + </screenshot> + + <para>More information and downloads from <ulink + url="http://fit-for-rules.sourceforge.net/"> + <citetitle>Here</citetitle> + </ulink></para> + </section> +</section> \ No newline at end of file Property changes on: labs/jbossrules/trunk/documentation/manual/en/Chapter-Deployment/Section-Testing.xml ___________________________________________________________________ Name: svn:eol-style + native Added: labs/jbossrules/trunk/documentation/manual/en/Chapter-Deployment/Testing1.png =================================================================== (Binary files differ) Property changes on: labs/jbossrules/trunk/documentation/manual/en/Chapter-Deployment/Testing1.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: labs/jbossrules/trunk/documentation/manual/en/Chapter-Deployment/Testing2.png =================================================================== (Binary files differ) Property changes on: labs/jbossrules/trunk/documentation/manual/en/Chapter-Deployment/Testing2.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: labs/jbossrules/trunk/documentation/manual/en/Chapter-Rule_Engine/Section-Working_Memory.xml =================================================================== --- labs/jbossrules/trunk/documentation/manual/en/Chapter-Rule_Engine/Section-Working_Memory.xml 2006-05-15 06:50:07 UTC (rev 4220) +++ labs/jbossrules/trunk/documentation/manual/en/Chapter-Rule_Engine/Section-Working_Memory.xml 2006-05-15 07:35:06 UTC (rev 4221) @@ -39,8 +39,9 @@ <para>Basically the reverse of Asserting. When you retract a fact, the working memory will no longer track that fact, and any rules that were dependent on that fact will not be activated. Note that it is possible to - have rules that depend on the "non existence" of fact, in which case - retracting a fact may cause a rule to activate.</para> + have rules that depend on the "non existence" of a fact, in which case + retracting a fact may cause a rule to activate (see the "not" and "exist" + keywords).</para> </section> <section> @@ -52,6 +53,40 @@ </section> <section> + <title><indexterm> + <primary>Logical Assertion</primary></indexterm> + </title> + + <para> + In a regular assertion, you need to explicitly retract a fact. In logical assertions, the fact that was asserted will be automatically retracted when + the conditions that asserted it in the first place are no longer true (its actually cleverer then this, if there are no possible conditions that could support the logical assertion, only then will it be retracted). + </para> + + <para> + This sounds confusing but its not really. Logical assertions are a powerful form of truth maintenance. A logically asserted fact can be thought of as a proxy for all the conditions that cause the rule it belongs to to be true. This means that you can use a logically asserted fact in a condition in other rules, without including all the conditions that triggered the logical assertion (meaning that all those conditions are not repeated everywhere). Logically asserted facts are like other facts, nothing special, you can even use "not" to check for the non existance of a logically asserted fact. + </para> + + <section> + <title>Example scenario</title> + <para> + An example may make things clearer. + Imagine a credit card processing application, processing transactions for a given account (and we have a working memory accumulating knowledge about a single accounts transaction). The rule engine is doing its best to decide if transactions are possibly fraudulent or not. Imagine this rule base basically has rules that kick in when there is "reason to be suspicious" and when "everything is normal". </para> + <para> + Of course there are many rules that operate no matter what (performing standard calculations etc). + Now there are possibly many reasons as to what could trigger a "reason to be suspicious": someone notifying the bank, a sequence of large transactions, transactions for geographically disparate transactions, or even reports of credit card theft. Rather then smattering all the little conditions in lots of rules, imagine there is a fact class called "SuspiciousAccount". </para> + <para> + Then there can be a series of rules whose job is to look for things that may raise suspicion, and if they fire, they simply assert a new SuspiciousAccount() instance. All the other rules just have conditions like "not SuspiciousAccount()" or "SuspiciousAccount()" depending on their needs. Note that this has the advantage of allowing there to be many rules around raising suspicion, without touching the other rules. When the facts causing the SuspiciousAccount() assertion are removed, the rule engine reverts back to the normal "mode" of operation (and for instance, a rule with "not SuspiciousAccount()" may kick in which flushes through any interrupted transactions). + </para> + <para> + If you have followed this far, you will note that truth maintenance like logical assertions allows rules to behave a little like a human would, and can certainly make the rules more managable. + </para> + + </section> + </section> + + + + <section> <title>Globals</title> <para>Globals are a named objects that can be passed in to the rule @@ -107,14 +142,14 @@ <para>Rule engines that are based around algorithms like RETE are technically statefull rule engines. That is, they work best when the RETE network is longer lived, being notified of changes, and accumulating facts - - that is where they shine. </para> + - that is where they shine.</para> <para>However, many scenarious simply require a stateless mode where all the facts (data) are supplied fresh to the rule engine and then the rules are invoked. Drools is fine in these scenarious as well - in fact, the RETE algorithm is still of benefit as often there will be scenarios in a stateless session where rules actions cause other rules to fire, or where - there are large numbers of facts to match with rules. </para> + there are large numbers of facts to match with rules.</para> <para>The JSR-94 api specifies statefull and stateless modes, but the equivalent in the native API is to simply create a new working memory |
From: <jbo...@li...> - 2006-05-15 06:50:12
|
Author: mic...@jb... Date: 2006-05-15 02:50:07 -0400 (Mon, 15 May 2006) New Revision: 4220 Modified: labs/jbossrules/trunk/documentation/manual/en/Chapter-Deployment/Section-Deployment.xml labs/jbossrules/trunk/documentation/manual/en/master.xml Log: improvements Modified: labs/jbossrules/trunk/documentation/manual/en/Chapter-Deployment/Section-Deployment.xml =================================================================== --- labs/jbossrules/trunk/documentation/manual/en/Chapter-Deployment/Section-Deployment.xml 2006-05-15 06:35:36 UTC (rev 4219) +++ labs/jbossrules/trunk/documentation/manual/en/Chapter-Deployment/Section-Deployment.xml 2006-05-15 06:50:07 UTC (rev 4220) @@ -56,7 +56,8 @@ "PackageDescr" object, which means that the rules are pre-parsed (for syntactic errors) but not compiled into the binary form. Use the PackageBuilder class to achieve this. You can of course use the XML form - for the rules if needed. <programlisting>PackageDescr, PackageBuilder, RuleBaseLoader</programlisting></para> + for the rules if needed. </para> + <programlisting>PackageDescr, PackageBuilder, RuleBaseLoader</programlisting> </section> <section> @@ -75,7 +76,8 @@ rules from the same package name can be merged together).</para> <para>Package objects themselves are serializable, hence they can be - sent over a network, or bound to JNDI, Session etc. <programlisting>PackageBuilder, RuleBase, org.drools.rule.Package</programlisting></para> + sent over a network, or bound to JNDI, Session etc. </para> + <programlisting>PackageBuilder, RuleBase, org.drools.rule.Package</programlisting> </section> <section> @@ -86,7 +88,8 @@ can be a useful option for when rulebases are updated as a whole - for short lived working memories. If existing working memories need to have rules changed on the fly, then it is best to deploy Package objects. - <programlisting>RuleBase, RuleBaseLoader</programlisting></para> + </para> + <programlisting>RuleBase, RuleBaseLoader</programlisting> </section> <section> @@ -134,15 +137,17 @@ check for changes) or a request to the runtime system (perhaps via a JMX interface). This is possibly the more common scenario.</para> - <screenshot> - <mediaobject> - <imageobject> - <imagedata fileref="DeploymentPatterns1.png" /> - </imageobject> - </mediaobject> - </screenshot> - </section> + </section> + + <screenshot> + <mediaobject> + <imageobject> + <imagedata fileref="DeploymentPatterns1.png" /> + </imageobject> + </mediaobject> + </screenshot> + <section> <title>Push style</title> @@ -150,15 +155,15 @@ "pushes" rules into the runtime system (either in source or binary form, as described above). This gives more control as to when the new rules take effect.</para> + </section> + <screenshot> + <mediaobject> + <imageobject> + <imagedata fileref="DeploymentPatterns2.png" /> + </imageobject> + </mediaobject> + </screenshot> - <screenshot> - <mediaobject> - <imageobject> - <imagedata fileref="DeploymentPatterns2.png" /> - </imageobject> - </mediaobject> - </screenshot> - </section> </section> </section> Modified: labs/jbossrules/trunk/documentation/manual/en/master.xml =================================================================== --- labs/jbossrules/trunk/documentation/manual/en/master.xml 2006-05-15 06:35:36 UTC (rev 4219) +++ labs/jbossrules/trunk/documentation/manual/en/master.xml 2006-05-15 06:50:07 UTC (rev 4220) @@ -147,8 +147,9 @@ </chapter> <chapter> - <title>Deployment</title> + <title>Deployment and Testing</title> <xi:include href="Chapter-Deployment/Section-Deployment.xml" /> + <xi:include href="Chapter-Deployment/Section-Testing.xml" /> </chapter> <chapter> |
From: <jbo...@li...> - 2006-05-15 06:35:43
|
Author: mic...@jb... Date: 2006-05-15 02:35:36 -0400 (Mon, 15 May 2006) New Revision: 4219 Modified: labs/jbossrules/trunk/drools-ide/src/main/java/org/drools/ide/editors/DRLRuleEditor2.java labs/jbossrules/trunk/drools-ide/src/main/java/org/drools/ide/editors/completion/RuleCompletionProcessor.java labs/jbossrules/trunk/drools-ide/src/main/java/org/drools/ide/editors/keywords.properties Log: added assertLogical, javadocs Modified: labs/jbossrules/trunk/drools-ide/src/main/java/org/drools/ide/editors/DRLRuleEditor2.java =================================================================== --- labs/jbossrules/trunk/drools-ide/src/main/java/org/drools/ide/editors/DRLRuleEditor2.java 2006-05-15 03:02:15 UTC (rev 4218) +++ labs/jbossrules/trunk/drools-ide/src/main/java/org/drools/ide/editors/DRLRuleEditor2.java 2006-05-15 06:35:36 UTC (rev 4219) @@ -8,8 +8,9 @@ import org.eclipse.ui.forms.editor.FormEditor; /** - * Generic rule editor for drools. - * @author Michael Neale + * This is a multi table editor wrapper for both the text editor and the RETE + * viewer. + * @author Kris. */ public class DRLRuleEditor2 extends FormEditor { Modified: labs/jbossrules/trunk/drools-ide/src/main/java/org/drools/ide/editors/completion/RuleCompletionProcessor.java =================================================================== --- labs/jbossrules/trunk/drools-ide/src/main/java/org/drools/ide/editors/completion/RuleCompletionProcessor.java 2006-05-15 03:02:15 UTC (rev 4218) +++ labs/jbossrules/trunk/drools-ide/src/main/java/org/drools/ide/editors/completion/RuleCompletionProcessor.java 2006-05-15 06:35:36 UTC (rev 4219) @@ -66,31 +66,18 @@ list.addAll(adapter.listConditionItems()); } else if (consequence.matcher(backText).matches()) { List dslConsequences = adapter.listConsequenceItems(); - Iterator iterator; addDSLProposals( list, prefix, dslConsequences ); if (!adapter.hasConsequences()) { - RuleCompletionProposal prop = new RuleCompletionProposal(prefix.length(), "modify", "modify();", 7); - prop.setImage(droolsIcon); - list.add(prop); - prop = new RuleCompletionProposal(prefix.length(), "retract", "retract();", 8); - prop.setImage(droolsIcon); - list.add(prop); - prop = new RuleCompletionProposal(prefix.length(), "assert", "assert();", 7); - prop.setImage(droolsIcon); - list.add(prop); + + addRHSCompletionProposals( list, + prefix ); - List functions = getFunctions(viewer); - iterator = functions.iterator(); - while (iterator.hasNext()) { - String name = (String) iterator.next() + "()"; - prop = new RuleCompletionProposal(prefix.length(), name, name + ";", name.length() - 1); - prop.setPriority(-1); - prop.setImage(methodIcon); - list.add(prop); - } + addRHSFunctionCompletionProposals( viewer, + list, + prefix ); } } else if (condition.matcher(backText).matches()) { List dslConditions = adapter.listConditionItems(); @@ -142,6 +129,39 @@ return null; } + private void addRHSFunctionCompletionProposals(ITextViewer viewer, + final List list, + final String prefix) throws CoreException, + DroolsParserException { + Iterator iterator; + RuleCompletionProposal prop; + List functions = getFunctions(viewer); + iterator = functions.iterator(); + while (iterator.hasNext()) { + String name = (String) iterator.next() + "()"; + prop = new RuleCompletionProposal(prefix.length(), name, name + ";", name.length() - 1); + prop.setPriority(-1); + prop.setImage(methodIcon); + list.add(prop); + } + } + + private void addRHSCompletionProposals(final List list, + final String prefix) { + RuleCompletionProposal prop = new RuleCompletionProposal(prefix.length(), "modify", "modify();", 7); + prop.setImage(droolsIcon); + list.add(prop); + prop = new RuleCompletionProposal(prefix.length(), "retract", "retract();", 8); + prop.setImage(droolsIcon); + list.add(prop); + prop = new RuleCompletionProposal(prefix.length(), "assert", "assert();", 7); + prop.setImage(droolsIcon); + list.add(prop); + prop = new RuleCompletionProposal(prefix.length(), "assertLogical", "assertLogical();", 14); + prop.setImage(droolsIcon); + list.add(prop); + } + private void addRuleHeaderItems(final List list, final String prefix) { list.add(new RuleCompletionProposal(prefix.length(), "salience", "salience ", droolsIcon)); Modified: labs/jbossrules/trunk/drools-ide/src/main/java/org/drools/ide/editors/keywords.properties =================================================================== --- labs/jbossrules/trunk/drools-ide/src/main/java/org/drools/ide/editors/keywords.properties 2006-05-15 03:02:15 UTC (rev 4218) +++ labs/jbossrules/trunk/drools-ide/src/main/java/org/drools/ide/editors/keywords.properties 2006-05-15 06:35:36 UTC (rev 4219) @@ -6,6 +6,7 @@ modify retract assert +assertLogical salience import expander |
From: <jbo...@li...> - 2006-05-15 03:02:29
|
Author: mic...@jb... Date: 2006-05-14 23:02:15 -0400 (Sun, 14 May 2006) New Revision: 4218 Modified: labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/Section-Spreadsheet.xml Log: typos Modified: labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/Section-Spreadsheet.xml =================================================================== --- labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/Section-Spreadsheet.xml 2006-05-14 23:24:48 UTC (rev 4217) +++ labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/Section-Spreadsheet.xml 2006-05-15 03:02:15 UTC (rev 4218) @@ -348,9 +348,9 @@ <entry>XOR-GROUP</entry> <entry>Cell values in this column mean that the rule-row belongs - to the given XOR group. An Xor group means that only one rule in - the named group will fire (ie the first one to fire cancells the - other rules activations).</entry> + to the given XOR/activation group group. An Xor group means that + only one rule in the named group will fire (ie the first one to + fire cancels the other rules activations).</entry> <entry>optional</entry> </row> |
From: <jbo...@li...> - 2006-05-14 23:24:54
|
Author: tirelli Date: 2006-05-14 19:24:48 -0400 (Sun, 14 May 2006) New Revision: 4217 Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/template/NLMappingItem.java Log: Quick fix for JBRULES-176 Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/template/NLMappingItem.java =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/template/NLMappingItem.java 2006-05-14 21:25:10 UTC (rev 4216) +++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/template/NLMappingItem.java 2006-05-14 23:24:48 UTC (rev 4217) @@ -50,7 +50,7 @@ public void setNaturalTemplate(String naturalTemplate) { - this.naturalTemplate = naturalTemplate; + this.naturalTemplate = naturalTemplate.replaceAll( "\\s*,\\s*", " , " ); } public void setScope(String scope) { @@ -64,9 +64,9 @@ public NLMappingItem(String naturalTemplate, String targetTemplate, String scope) { - this.naturalTemplate = naturalTemplate; - this.targetTemplate = targetTemplate; - this.scope = scope; + this.setNaturalTemplate( naturalTemplate ); + this.setTargetTemplate( targetTemplate ); + this.setScope( scope ); } public String getNaturalTemplate() { |
Author: tirelli Date: 2006-05-14 17:25:10 -0400 (Sun, 14 May 2006) New Revision: 4216 Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/LeapsTest.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/HashedObjectSinkList.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectSinkList.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectSource.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooToJungVisitor.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/RightInputAdapterNode.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/RuleBaseImpl.java labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/AlphaNodeTest.java labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/JoinNodeTest.java labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/LeftInputAdapterNodeTest.java labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/ObjectSourceTest.java labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/ReteTest.java labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/RuleBaseImplTest.java Log: Fixing JBRULES-256: package management problems Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java 2006-05-13 23:22:04 UTC (rev 4215) +++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java 2006-05-14 21:25:10 UTC (rev 4216) @@ -218,7 +218,7 @@ assertEquals( bill, list.get( 0 ) ); } - + public void testPropertyChangeSupport() throws Exception { PackageBuilder builder = new PackageBuilder(); builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "Test_PropertyChange.drl" ) ) ); @@ -232,24 +232,28 @@ workingMemory.setGlobal( "list", list ); - State state = new State("initial"); - workingMemory.assertObject( state, true ); + State state = new State( "initial" ); + workingMemory.assertObject( state, + true ); workingMemory.fireAllRules(); - - assertEquals(1, list.size()); - + assertEquals( 1, + list.size() ); + state.setFlag( true ); - assertEquals(1, list.size()); - + assertEquals( 1, + list.size() ); + workingMemory.fireAllRules(); - assertEquals(2, list.size()); - + assertEquals( 2, + list.size() ); + state.setState( "finished" ); workingMemory.fireAllRules(); - assertEquals(3, list.size()); + assertEquals( 3, + list.size() ); - } + } public void testBigDecimal() throws Exception { @@ -1452,8 +1456,17 @@ builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_Dynamic4.drl" ) ) ); Package pkg = builder.getPackage(); - org.drools.reteoo.RuleBaseImpl ruleBase = new org.drools.reteoo.RuleBaseImpl(); + org.drools.reteoo.RuleBaseImpl reteooRuleBase = null; + org.drools.leaps.RuleBaseImpl leapsRuleBase = null; + RuleBase ruleBase = getRuleBase(); + //org.drools.reteoo.RuleBaseImpl ruleBase = new org.drools.reteoo.RuleBaseImpl(); + if ( ruleBase instanceof org.drools.reteoo.RuleBaseImpl ) { + reteooRuleBase = (org.drools.reteoo.RuleBaseImpl) ruleBase; + } else if ( ruleBase instanceof org.drools.leaps.RuleBaseImpl ) { + leapsRuleBase = (org.drools.leaps.RuleBaseImpl) ruleBase; + } ruleBase.addPackage( pkg ); + WorkingMemory workingMemory = ruleBase.newWorkingMemory(); List list = new ArrayList(); @@ -1488,29 +1501,113 @@ assertEquals( 11, workingMemory.getAgenda().getActivations().length ); - ruleBase.removeRule( "org.drools.test", - "Who likes Stilton" ); + if ( reteooRuleBase != null ) { + reteooRuleBase.removeRule( "org.drools.test", + "Who likes Stilton" ); + assertEquals( 8, + workingMemory.getAgenda().getActivations().length ); - assertEquals( 8, - workingMemory.getAgenda().getActivations().length ); + reteooRuleBase.removeRule( "org.drools.test", + "like cheese" ); - ruleBase.removeRule( "org.drools.test", - "like cheese" ); + Cheese muzzarela = new Cheese( "muzzarela", + 5 ); + workingMemory.assertObject( muzzarela ); - Cheese muzzarela = new Cheese( "muzzarela", - 5 ); - workingMemory.assertObject( muzzarela ); + assertEquals( 4, + workingMemory.getAgenda().getActivations().length ); - assertEquals( 4, - workingMemory.getAgenda().getActivations().length ); + reteooRuleBase.removePackage( "org.drools.test" ); - ruleBase.removePackage( "org.drools.test" ); + assertEquals( 0, + workingMemory.getAgenda().getActivations().length ); + } else if ( leapsRuleBase != null ) { + leapsRuleBase.removeRule( "org.drools.test", + "Who likes Stilton" ); + assertEquals( 8, + workingMemory.getAgenda().getActivations().length ); - assertEquals( 0, - workingMemory.getAgenda().getActivations().length ); + leapsRuleBase.removeRule( "org.drools.test", + "like cheese" ); + Cheese muzzarela = new Cheese( "muzzarela", + 5 ); + workingMemory.assertObject( muzzarela ); + + assertEquals( 4, + workingMemory.getAgenda().getActivations().length ); + + leapsRuleBase.removePackage( "org.drools.test" ); + + assertEquals( 0, + workingMemory.getAgenda().getActivations().length ); + + } } + public void testDynamicRuleRemovalsUnusedWorkingMemory() throws Exception { + + PackageBuilder builder = new PackageBuilder(); + builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_Dynamic1.drl" ) ) ); + builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_Dynamic2.drl" ) ) ); + builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_Dynamic3.drl" ) ) ); + builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_Dynamic4.drl" ) ) ); + Package pkg = builder.getPackage(); + + org.drools.reteoo.RuleBaseImpl reteooRuleBase = null; + org.drools.leaps.RuleBaseImpl leapsRuleBase = null; + RuleBase ruleBase = getRuleBase(); + //org.drools.reteoo.RuleBaseImpl ruleBase = new org.drools.reteoo.RuleBaseImpl(); + if ( ruleBase instanceof org.drools.reteoo.RuleBaseImpl ) { + reteooRuleBase = (org.drools.reteoo.RuleBaseImpl) ruleBase; + } else if ( ruleBase instanceof org.drools.leaps.RuleBaseImpl ) { + leapsRuleBase = (org.drools.leaps.RuleBaseImpl) ruleBase; + } + ruleBase.addPackage( pkg ); + + WorkingMemory workingMemory = ruleBase.newWorkingMemory(); + + if ( reteooRuleBase != null ) { + assertEquals( 1, + reteooRuleBase.getPackages().length ); + assertEquals( 4, + reteooRuleBase.getPackages()[0].getRules().length ); + + reteooRuleBase.removeRule( "org.drools.test", + "Who likes Stilton" ); + assertEquals( 3, + reteooRuleBase.getPackages()[0].getRules().length ); + + reteooRuleBase.removeRule( "org.drools.test", + "like cheese" ); + assertEquals( 2, + reteooRuleBase.getPackages()[0].getRules().length ); + + reteooRuleBase.removePackage( "org.drools.test" ); + assertEquals( 0, + reteooRuleBase.getPackages().length ); + } else if ( leapsRuleBase != null ) { + assertEquals( 1, + leapsRuleBase.getPackages().length ); + assertEquals( 4, + leapsRuleBase.getPackages()[0].getRules().length ); + + leapsRuleBase.removeRule( "org.drools.test", + "Who likes Stilton" ); + assertEquals( 3, + leapsRuleBase.getPackages()[0].getRules().length ); + + leapsRuleBase.removeRule( "org.drools.test", + "like cheese" ); + assertEquals( 2, + leapsRuleBase.getPackages()[0].getRules().length ); + + leapsRuleBase.removePackage( "org.drools.test" ); + assertEquals( 0, + leapsRuleBase.getPackages().length ); + } + } + public void testNullValuesIndexing() throws Exception { Reader reader = new InputStreamReader( getClass().getResourceAsStream( "test_NullValuesIndexing.drl" ) ); Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/LeapsTest.java =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/LeapsTest.java 2006-05-13 23:22:04 UTC (rev 4215) +++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/LeapsTest.java 2006-05-14 21:25:10 UTC (rev 4216) @@ -162,4 +162,13 @@ assertTrue( "rule2", list.contains( "rule2" ) ); } + + public void testDynamicRuleRemovals() throws Exception { + // TODO FIXME + } + + public void testDynamicRuleRemovalsUnusedWorkingMemory() throws Exception { + // TODO FIXME + } + } Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/HashedObjectSinkList.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/HashedObjectSinkList.java 2006-05-13 23:22:04 UTC (rev 4215) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/HashedObjectSinkList.java 2006-05-14 21:25:10 UTC (rev 4216) @@ -18,6 +18,7 @@ import java.io.Serializable; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -262,6 +263,7 @@ * * This method is not efficient and shall be used only for debugging and * test purposes. + * Also, the list returned is an unmodifiable list to prevent misusage of it. */ public List getObjectsAsList() { List list = new ArrayList(); @@ -270,7 +272,11 @@ list.addAll( wrapper.getAllNodes() ); } list.addAll( this.otherSinks ); - return list; + return Collections.unmodifiableList( list ); } + public int size() { + return this.hashedSinks.size()+this.otherSinks.size(); + } + } Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectSinkList.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectSinkList.java 2006-05-13 23:22:04 UTC (rev 4215) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectSinkList.java 2006-05-14 21:25:10 UTC (rev 4216) @@ -51,6 +51,12 @@ * @return */ public boolean remove(ObjectSink objectSink); + + /** + * Returns the number of ObjectSinks in this list + * @return + */ + public int size(); /** * Returns the last added object sink. @@ -80,6 +86,7 @@ * Returns a list with all object sinks * This may be an inneficient method to call, so we recomend using it only for * tests and debug purposes + * Also, it returns an unmodifiable list to prevent misuse * * @return */ Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectSource.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectSource.java 2006-05-13 23:22:04 UTC (rev 4215) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectSource.java 2006-05-14 21:25:10 UTC (rev 4216) @@ -148,7 +148,15 @@ * @return The <code>ObjectsSinks</code> that receive propagated * <code>FactHandles</code>. */ - public List getObjectSinks() { + public ObjectSinkList getObjectSinks() { + return this.objectSinks; + } + + /** + * Returns the object sinks as an unmodifiable list + * @return + */ + public List getObjectSinksAsList() { return this.objectSinks.getObjectsAsList(); } Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooToJungVisitor.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooToJungVisitor.java 2006-05-13 23:22:04 UTC (rev 4215) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooToJungVisitor.java 2006-05-14 21:25:10 UTC (rev 4216) @@ -125,7 +125,7 @@ List list = null; if ( node instanceof ObjectSource ) { - list = ((ObjectSource) node).getObjectSinks(); + list = ((ObjectSource) node).getObjectSinksAsList(); } else if ( node instanceof TupleSource ) { list = ((TupleSource) node).getTupleSinks(); } Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/RightInputAdapterNode.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/RightInputAdapterNode.java 2006-05-13 23:22:04 UTC (rev 4215) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/RightInputAdapterNode.java 2006-05-14 21:25:10 UTC (rev 4216) @@ -121,7 +121,7 @@ public void remove(BaseNode node, WorkingMemoryImpl[] workingMemories) { - getObjectSinks().remove( node ); + getObjectSinks().remove( (ObjectSink) node ); removeShare(); if ( this.sharedCount < 0 ) { this.tupleSource.remove( this, Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/RuleBaseImpl.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/RuleBaseImpl.java 2006-05-13 23:22:04 UTC (rev 4215) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/RuleBaseImpl.java 2006-05-14 21:25:10 UTC (rev 4216) @@ -25,6 +25,7 @@ import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -382,7 +383,7 @@ compilationData.putAllInvokers( newCompilationData.getInvokers() ); // Add globals - for ( Iterator it = globals.keySet().iterator(); it.hasNext(); ) { + for ( Iterator it = newPkg.getGlobals().keySet().iterator(); it.hasNext(); ) { String identifier = (String) it.next(); Class type = (Class) globals.get( identifier ); if ( globals.containsKey( identifier ) && !globals.get( identifier ).equals( type ) ) { @@ -390,6 +391,7 @@ newPkg ); } } + globals.putAll( newPkg.getGlobals() ); } private void addRule(Rule rule) throws InvalidPatternException { @@ -420,6 +422,24 @@ pkg.clear(); + // getting the list of referenced globals + Set referencedGlobals = new HashSet(); + for( Iterator it = this.pkgs.values().iterator(); it.hasNext(); ) { + org.drools.rule.Package pkgref = (org.drools.rule.Package) it.next(); + if(pkgref != pkg) { + referencedGlobals.addAll( pkgref.getGlobals().keySet() ); + } + } + // removing globals declared inside the package that are not shared + for( Iterator it = pkg.getGlobals().keySet().iterator(); it.hasNext(); ) { + String globalName = (String) it.next(); + if( !referencedGlobals.contains( globalName ) ) { + this.globals.remove( globalName ); + } + } + // removing the package itself from the list + this.pkgs.remove( pkg.getName() ); + // Iterate and unlock for ( Iterator it = this.workingMemories.keySet().iterator(); it.hasNext(); ) { WorkingMemoryImpl workingMemory = (WorkingMemoryImpl) it.next(); Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/AlphaNodeTest.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/AlphaNodeTest.java 2006-05-13 23:22:04 UTC (rev 4215) +++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/AlphaNodeTest.java 2006-05-14 21:25:10 UTC (rev 4216) @@ -46,12 +46,12 @@ assertEquals( 2, alphaNode.getId() ); assertLength( 0, - source.getObjectSinks() ); + source.getObjectSinksAsList() ); alphaNode.attach(); assertLength( 1, - source.getObjectSinks() ); + source.getObjectSinksAsList() ); assertSame( alphaNode, - source.getObjectSinks().get( 0 ) ); + source.getObjectSinks().getLastObjectSink() ); } public void testMemory() { Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/JoinNodeTest.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/JoinNodeTest.java 2006-05-13 23:22:04 UTC (rev 4215) +++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/JoinNodeTest.java 2006-05-14 21:25:10 UTC (rev 4216) @@ -77,7 +77,7 @@ this.node.getId() ); assertLength( 0, - this.objectSource.getObjectSinks() ); + this.objectSource.getObjectSinksAsList() ); assertLength( 0, this.tupleSource.getTupleSinks() ); @@ -85,13 +85,13 @@ this.node.attach(); assertLength( 1, - this.objectSource.getObjectSinks() ); + this.objectSource.getObjectSinksAsList() ); assertLength( 1, this.tupleSource.getTupleSinks() ); assertSame( this.node, - this.objectSource.getObjectSinks().get( 0 ) ); + this.objectSource.getObjectSinks().getLastObjectSink() ); assertSame( this.node, this.tupleSource.getTupleSinks().get( 0 ) ); Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/LeftInputAdapterNodeTest.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/LeftInputAdapterNodeTest.java 2006-05-13 23:22:04 UTC (rev 4215) +++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/LeftInputAdapterNodeTest.java 2006-05-14 21:25:10 UTC (rev 4216) @@ -56,15 +56,15 @@ liaNode.getId() ); assertLength( 0, - source.getObjectSinks() ); + source.getObjectSinksAsList() ); liaNode.attach(); assertLength( 1, - source.getObjectSinks() ); + source.getObjectSinksAsList() ); assertSame( liaNode, - source.getObjectSinks().get( 0 ) ); + source.getObjectSinks().getLastObjectSink() ); } /** Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/ObjectSourceTest.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/ObjectSourceTest.java 2006-05-13 23:22:04 UTC (rev 4215) +++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/ObjectSourceTest.java 2006-05-14 21:25:10 UTC (rev 4216) @@ -40,15 +40,15 @@ public void testAddObjectSink() { MockObjectSource source = new MockObjectSource( 15 ); assertLength( 0, - source.getObjectSinks() ); + source.getObjectSinksAsList() ); source.addObjectSink( new MockObjectSink() ); assertLength( 1, - source.getObjectSinks() ); + source.getObjectSinksAsList() ); source.addObjectSink( new MockObjectSink() ); assertLength( 2, - source.getObjectSinks() ); + source.getObjectSinksAsList() ); } public void testPropagateAssertObject() throws Exception { Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/ReteTest.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/ReteTest.java 2006-05-13 23:22:04 UTC (rev 4215) +++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/ReteTest.java 2006-05-14 21:25:10 UTC (rev 4216) @@ -140,7 +140,7 @@ null, workingMemory ); - MockObjectSink sink1 = (MockObjectSink) objectTypeNode.getObjectSinks().get( 0 ); + MockObjectSink sink1 = (MockObjectSink) objectTypeNode.getObjectSinksAsList().get( 0 ); assertLength( 0, sink1.getAsserted() ); @@ -187,7 +187,7 @@ null, workingMemory ); - MockObjectSink sink1 = (MockObjectSink) objectTypeNode.getObjectSinks().get( 0 ); + MockObjectSink sink1 = (MockObjectSink) objectTypeNode.getObjectSinksAsList().get( 0 ); assertLength( 0, sink1.getRetracted() ); Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/RuleBaseImplTest.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/RuleBaseImplTest.java 2006-05-13 23:22:04 UTC (rev 4215) +++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/RuleBaseImplTest.java 2006-05-14 21:25:10 UTC (rev 4216) @@ -17,7 +17,10 @@ +import junit.framework.Assert; + import org.drools.DroolsTestCase; +import org.drools.RuleBase; import org.drools.WorkingMemory; public class RuleBaseImplTest extends DroolsTestCase { @@ -89,5 +92,77 @@ assertFalse( this.ruleBase.getWorkingMemories().contains( wm5 ) ); assertFalse( this.ruleBase.getWorkingMemories().contains( wm6 ) ); } + + public void testAddPackage() throws Exception { + org.drools.rule.Package pkg1 = new org.drools.rule.Package("org.droos.test"); + pkg1.addGlobal( "global1", Object.class ); + pkg1.addGlobal( "global2", Object.class ); + + org.drools.rule.Package pkg2 = new org.drools.rule.Package("org.droos.test"); + pkg2.addGlobal( "global1", Object.class ); + pkg2.addGlobal( "global3", Object.class ); + + org.drools.rule.Package pkg3 = new org.drools.rule.Package("org.droos.test2"); + pkg3.addGlobal( "global3", Object.class ); + pkg3.addGlobal( "global4", Object.class ); + + this.ruleBase.addPackage( pkg1 ); + // one package + assertLength( 1, this.ruleBase.getPackages() ); + // two globals + assertLength( 2, this.ruleBase.getGlobals().values() ); + // two globals in the package also + assertLength( 2, this.ruleBase.getPackages()[0].getGlobals().values() ); + + this.ruleBase.addPackage( pkg2 ); + // packages merged, so still 1 package + assertLength( 1, this.ruleBase.getPackages() ); + // globals merged, so 3 globals total + assertLength( 3, this.ruleBase.getGlobals().values() ); + // three globals in the package also + assertLength( 3, this.ruleBase.getPackages()[0].getGlobals().values() ); + this.ruleBase.addPackage( pkg3 ); + // new package, so now we have 2 package + assertLength( 2, this.ruleBase.getPackages() ); + // globals partially merged, so 4 globals total + assertLength( 4, this.ruleBase.getGlobals().values() ); + // two globals in the package + org.drools.rule.Package[] pkgs = this.ruleBase.getPackages(); + for(int i = 0; i < pkgs.length; i++) { + if(pkgs[i].getName().equals( pkg3.getName() )) { + assertLength( 2, pkgs[i].getGlobals().values() ); + } + } + } + + public void testRemovePackage() throws Exception { + org.drools.rule.Package pkg1 = new org.drools.rule.Package("org.droos.test"); + pkg1.addGlobal( "global1", Object.class ); + pkg1.addGlobal( "global2", Object.class ); + + org.drools.rule.Package pkg2 = new org.drools.rule.Package("org.droos.test"); + pkg2.addGlobal( "global1", Object.class ); + pkg2.addGlobal( "global3", Object.class ); + + org.drools.rule.Package pkg3 = new org.drools.rule.Package("org.droos.test2"); + pkg3.addGlobal( "global3", Object.class ); + pkg3.addGlobal( "global4", Object.class ); + + this.ruleBase.addPackage( pkg1 ); + this.ruleBase.addPackage( pkg2 ); + this.ruleBase.addPackage( pkg3 ); + + this.ruleBase.removePackage( pkg1.getName() ); + // packages were partially merged when adding, so removal + // shall left only package 3 behind + assertLength( 1, this.ruleBase.getPackages() ); + assertLength( 2, this.ruleBase.getGlobals().values() ); + + this.ruleBase.removePackage( pkg3.getName() ); + assertLength( 0, this.ruleBase.getPackages() ); + assertLength( 0, this.ruleBase.getGlobals().values() ); + + } + } \ No newline at end of file |
Author: unibrew Date: 2006-05-13 19:22:04 -0400 (Sat, 13 May 2006) New Revision: 4215 Modified: labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersEntity.java labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersMDB.java labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersService.java labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersServiceBean.java labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/CountersServiceInterface.java labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCounterDescriptor.java labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDB.java labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDescriptor.java labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersWatcher.java Log: [JBLAB-665] DownloadCounters commented, cleared from SOD and properly tested. Modified: labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersEntity.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersEntity.java 2006-05-13 14:12:32 UTC (rev 4214) +++ labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersEntity.java 2006-05-13 23:22:04 UTC (rev 4215) @@ -34,6 +34,7 @@ * * @author Ryszard Kozmik * + * EJB3 Entity which is used to persist in database all download counters for projects. */ @Entity @Table(name = "jblab_counters") @@ -47,6 +48,9 @@ private boolean visible; + /** + * Default constructor for CountersEntity sets its attributes to default values. + */ public CountersEntity () { this.path = ""; @@ -55,6 +59,9 @@ this.visible = true; } + /** + * Main constructor for CountersEntity which takes all possible values to set all its attributes. + */ public CountersEntity (String path, long initValue, String projectId, boolean visible, String order) { this.path = path; Modified: labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersMDB.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersMDB.java 2006-05-13 14:12:32 UTC (rev 4214) +++ labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersMDB.java 2006-05-13 23:22:04 UTC (rev 4215) @@ -37,7 +37,8 @@ /** - * + * EJB3 Message Driven Bean class which is used for receiving messages from + * DownloadCounters. It is responsible for incrementing requested counter. * @author Ryszard Kozmik * */ @@ -53,6 +54,9 @@ private static Logger logger; + /** + * Just default constructor which gets Logger instance for this class. + */ public CountersMDB() { if (logger == null) @@ -62,6 +66,11 @@ } } + /** + * Method responsible for getting mesages sent from DownloadCounters. + * It gets message and increments a counter for given in message filepath. + * @param msg + */ public void onMessage(Message msg) { try @@ -71,7 +80,6 @@ CountersService countersService = (CountersService) ctx.lookup(CountersServiceInterface.jndiName); countersService.incrementCounter(txtMsg.getText()); - System.out.println("HELLO!!: "+txtMsg.getText()); } catch (NamingException e) { Modified: labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersService.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersService.java 2006-05-13 14:12:32 UTC (rev 4214) +++ labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersService.java 2006-05-13 23:22:04 UTC (rev 4215) @@ -29,7 +29,7 @@ /** - * + * Local interface for CountersServiceBean class. * @author Ryszard Kozmik * */ Modified: labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersServiceBean.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersServiceBean.java 2006-05-13 14:12:32 UTC (rev 4214) +++ labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersServiceBean.java 2006-05-13 23:22:04 UTC (rev 4215) @@ -40,16 +40,22 @@ /** * * @author Ryszard Kozmik - * + * + * EJB3 Stateless Session Bean used as a service for managing DownloadCounters persistence. */ @Stateless @LocalBinding (jndiBinding=CountersServiceInterface.jndiName) public class CountersServiceBean implements CountersService { + // Registering with counters persistence context @PersistenceContext (unitName="counters") protected EntityManager em; + /** + * This method gets all counters from database and returns a Map object with them. + * @return Map<String,Counter> containging all download counters from database. + */ public Map<String,Counter> getCountersMap() { List<CountersEntity> countersRows = em.createQuery("from CountersEntity e").getResultList(); @@ -65,13 +71,16 @@ return countersMap; } + /** + * Persists downloadCounters given in execution parameter to database. + * @param downloadCounters + * Map<String,Counter> containing all download counters for all projects. + */ public void updateCounters(Map<String,Counter> downloadCounters) { - System.out.println("HELLO UPDATECOUNTERS"); synchronized (downloadCounters) { for (String path : downloadCounters.keySet()) { - System.out.println("UPDATING PATH: "+path); Counter counter = downloadCounters.get(path); CountersEntity ce = em.find(CountersEntity.class,path); if (ce==null) @@ -97,10 +106,18 @@ } } + /** + * Method increments counter for specified in parameter file path. + * @param path + * Filepath for which counter needs to be increased. + */ public void incrementCounter (String path) { - System.out.println("CountersService: "+path); CountersEntity ce = em.find(CountersEntity.class,path); + if (ce==null) + { + return ; + } ce.setCounterValue(ce.getCounterValue()+1); em.persist(ce); } Modified: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/CountersServiceInterface.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/CountersServiceInterface.java 2006-05-13 14:12:32 UTC (rev 4214) +++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/CountersServiceInterface.java 2006-05-13 23:22:04 UTC (rev 4215) @@ -26,7 +26,7 @@ import java.util.Map; /** - * + * Interface showing what methods are in Session Bean service. * @author Ryszard Kozmik * */ Modified: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCounterDescriptor.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCounterDescriptor.java 2006-05-13 14:12:32 UTC (rev 4214) +++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCounterDescriptor.java 2006-05-13 23:22:04 UTC (rev 4215) @@ -136,7 +136,7 @@ if (property.getNodeType()== Node.ELEMENT_NODE){ String visibilityAtt = XmlTools.getAttributeValue(property,VISIBILITY); boolean visibility = true; - if (visibilityAtt!=null && visibilityAtt.equals(FALSE)) { + if (visibilityAtt!=null && visibilityAtt.trim().compareToIgnoreCase(FALSE)==0) { visibility = false; } if (property.getNodeName().equals(LINK) && XmlTools.unmarshallText(property) != null Modified: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDB.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDB.java 2006-05-13 14:12:32 UTC (rev 4214) +++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDB.java 2006-05-13 23:22:04 UTC (rev 4215) @@ -46,9 +46,18 @@ public class DownloadCountersDB extends DownloadCountersDescriptor { - + + // InitialContext is used for getting CountersEntity bean. protected InitialContext ctx; + /** + * Main constructor of this class which gets all counters from database, + * then it compares them with information gained from xml projects' descriptors + * and finally after synchronization database is updated with the changes. + * @param portalName + * @param cm + * ContentManager instance needed to get xml descriptors. + */ public DownloadCountersDB(String portalName, ContentManager cm) { super(); @@ -59,12 +68,6 @@ CountersServiceInterface countersService = (CountersServiceInterface) ctx.lookup(CountersServiceInterface.jndiName); downloadCounters = countersService.getCountersMap(); - - // SOD - for (String path : downloadCounters.keySet()) - { - System.out.println("SOD 1 Path: "+path+" Value: "+downloadCounters.get(path)); - } // Getting Map containing pairs of ProjectId and shotoku Node // which refers to projects' download counter descriptor. @@ -77,13 +80,6 @@ countersService.updateCounters(downloadCounters); - - // SOD - for (String path : downloadCounters.keySet()) - { - System.out.println("SOD 2 Path: "+path+" Value: "+downloadCounters.get(path)); - } - } catch (Exception e) { @@ -100,13 +96,6 @@ */ public void synchronizeWithFile(String portalName) { - - // SOD - for (String path : downloadCounters.keySet()) - { - System.out.println("SOD 4 Path: "+path+" Value: "+downloadCounters.get(path)); - } - try { CountersServiceInterface countersService = @@ -117,11 +106,6 @@ { getLogger().error("Failed to persist downloadCounters", e); } - // SOD - for (String path : downloadCounters.keySet()) - { - System.out.println("SOD 4.5 Path: "+path+" Value: "+downloadCounters.get(path)); - } } /** @@ -137,13 +121,14 @@ { // Status change to inform about counters modification. downloadCounters.get(link).increment(); - System.out.println("DownloadCounters: "+link); try { //CountersServiceInterface countersService = // (CountersServiceInterface) ctx.lookup(CountersServiceInterface.jndiName); //countersService.incrementCounter(link); + // This code sends message to counters' MDB with message + // containing filepath of which counter has to be increased QueueSession sess = null; Queue queue = null; queue = (Queue) ctx.lookup("queue/jblab_counters"); Modified: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDescriptor.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDescriptor.java 2006-05-13 14:12:32 UTC (rev 4214) +++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDescriptor.java 2006-05-13 23:22:04 UTC (rev 4215) @@ -245,12 +245,6 @@ removeLinksForProjects (projects); } - // SOD - for (String path : downloadCounters.keySet()) - { - System.out.println("SOD 3 Path: "+path+" Value: "+downloadCounters.get(path)); - } - // Iterating through projects nodes containing download counter descriptors. for (String projectId:counters.keySet()){ try { @@ -289,13 +283,7 @@ } } - - // SOD - for (String path : downloadCounters.keySet()) - { - System.out.println("SOD 5 Path: "+path+" Value: "+downloadCounters.get(path)); - } - + // Changing status to false becouse downloadCounters Map // is now synchronized with projects' download counter descriptors. changeStatus=false; @@ -308,24 +296,11 @@ * @param linksToDelete * List<String> of links which should be removed. */ - private synchronized void removeLinksFromCounting (List<String> linksToDelete) { - - // SOD - for (String path : downloadCounters.keySet()) - { - System.out.println("SOD 6 Path: "+path+" Value: "+downloadCounters.get(path)); - } - + private synchronized void removeLinksFromCounting (List<String> linksToDelete) { // Removing links which shouldn't be tracked any more. for (String link:linksToDelete) { downloadCounters.remove(link); } - - // SOD - for (String path : downloadCounters.keySet()) - { - System.out.println("SOD 7 Path: "+path+" Value: "+downloadCounters.get(path)); - } } /** @@ -360,30 +335,13 @@ * Project id name for which the links are added. */ private synchronized void addLinksForCounting (Map<String,Boolean> links,String projectId,Sorting sorting) { - // SOD - for (String path : downloadCounters.keySet()) - { - System.out.println("SOD 10 Path: "+path+" Value: "+downloadCounters.get(path)); - } // Adding new download links for tracking. for (String link:links.keySet()) { downloadCounters.put(link,new Counter(0,projectId,links.get(link),sorting)); } - // SOD - for (String path : downloadCounters.keySet()) - { - System.out.println("SOD 11 Path: "+path+" Value: "+downloadCounters.get(path)); - } } - private synchronized void removeLinksForProjects (Set<String> projects) { - - // SOD - for (String path : downloadCounters.keySet()) - { - System.out.println("SOD 8 Path: "+path+" Value: "+downloadCounters.get(path)); - } - + private synchronized void removeLinksForProjects (Set<String> projects) { Set<String> countersLinks = downloadCounters.keySet(); List<String> linksForRemoval = new LinkedList<String>(); for (String link: countersLinks) { @@ -392,12 +350,6 @@ } } downloadCounters.keySet().removeAll(linksForRemoval); - - // SOD - for (String path : downloadCounters.keySet()) - { - System.out.println("SOD 9 Path: "+path+" Value: "+downloadCounters.get(path)); - } } private synchronized Set<String> getTrackedProjects () { @@ -437,23 +389,7 @@ * Map<String,Long> containing link:value pairs. */ public synchronized Map<String,Long> getValuesForPortlet (String projectId) { - - System.out.println("GETVALUESFORPORTLET"); - System.out.println("PROJECTID: "+projectId); - // SOD - for (String path : downloadCounters.keySet()) - { - System.out.println("SOD 12 Path: "+path+" Value: "+downloadCounters.get(path)+ - " ProjectId: "+downloadCounters.get(path).getProjectId()+" Visible:"+downloadCounters.get(path).getVisible()); - } - Map<String,Boolean> links = getProjectLinks(projectId); - - //SOD - for (String project : links.keySet()) - { - System.out.println("SOD: PROJECTLINK: "+project+" BOOLEAN: "+links.get(project)); - } - + Map<String,Boolean> links = getProjectLinks(projectId); Map<String,Long> values = null; if (links.size()==0) { values = new Hashtable<String,Long>(0); @@ -508,18 +444,6 @@ values.put(link,downloadCounters.get(link).getValue()); } } - - for (String link : values.keySet()) - { - System.out.println("SOD: VALUES || LINK: "+link+" LONGVAL: "+values.get(link)); - } - - // SOD - for (String path : downloadCounters.keySet()) - { - System.out.println("SOD 13 Path: "+path+" Value: "+downloadCounters.get(path).getValue() + - " ProjectId: "+downloadCounters.get(path).getProjectId()+" Visible:"+downloadCounters.get(path).getVisible()); - } return values; } Modified: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersWatcher.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersWatcher.java 2006-05-13 14:12:32 UTC (rev 4214) +++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersWatcher.java 2006-05-13 23:22:04 UTC (rev 4215) @@ -89,7 +89,7 @@ * If the object is changed the method returns new object if not returns null. */ public Object nodeUpdate(String portalName, Object currentValue) { - if (currentValue==null || rw.checkResources() + if (currentValue==null || rw.checkResources() || !checkForNewResources((DownloadCountersDescriptor)currentValue,portalName)) { return getDescriptor(portalName); } else if (((DownloadCountersDescriptor)currentValue).hasChanged()){ @@ -101,6 +101,12 @@ return null; } + /** + * Method checks if there was no new xml project' descriptor added. + * @param desc + * @param portalName + * @return + */ private boolean checkForNewResources (DownloadCountersDescriptor desc, String portalName) { return counterDescriptors.containsAll(desc.getDownloadDescriptors(portalName).keySet()); } |
Author: bagerman Date: 2006-05-13 10:12:32 -0400 (Sat, 13 May 2006) New Revision: 4214 Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/LeapsTest.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/FactTable.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/WorkingMemoryImpl.java Log: JBRULES-233 for leaps Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/LeapsTest.java =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/LeapsTest.java 2006-05-13 10:11:23 UTC (rev 4213) +++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/LeapsTest.java 2006-05-13 14:12:32 UTC (rev 4214) @@ -162,9 +162,4 @@ assertTrue( "rule2", list.contains( "rule2" ) ); } - - public void testLogicalAssertionsDynamicRule() throws Exception { - // TODO FIXME - } - } Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java 2006-05-13 10:11:23 UTC (rev 4213) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java 2006-05-13 14:12:32 UTC (rev 4214) @@ -111,7 +111,9 @@ protected long propagationIdCounter; private ReentrantLock lock = new ReentrantLock( ); - + + private List factQueue = new ArrayList( ); + public AbstractWorkingMemory(RuleBase ruleBase, FactHandleFactory handleFactory) { this.ruleBase = ruleBase; @@ -377,8 +379,52 @@ return this.justified; } + public long getNextPropagationIdCounter() { + return this.propagationIdCounter++; + } + abstract public void dispose(); + public void removeLogicalDependencies(Activation activation, + PropagationContext context, + Rule rule) throws FactException { + org.drools.util.LinkedList list = activation.getLogicalDependencies(); + if ( list == null || list.isEmpty() ) { + return; + } + for ( LogicalDependency node = (LogicalDependency) list.getFirst(); node != null; node = (LogicalDependency) node.getNext() ) { + InternalFactHandle handle = (InternalFactHandle) node.getFactHandle(); + Set set = (Set) this.justified.get( handle.getId( ) ); + // check set for null because in some weird cases on logical assertion + // it comes back with the same activation/handle and tries on + // already cleaned this.justified. only happens on removal of rule + // from the working memory + if (set != null) { + set.remove( node ); + if (set.isEmpty( )) { + this.justified.remove( handle.getId( ) ); + // this needs to be scheduled so we don't upset the current + // working memory operation + this.factQueue.add( new WorkingMemoryRetractAction( handle, + false, + true, + context.getRuleOrigin( ), + context.getActivationOrigin( ) ) ); + } + } + } + } + + public void removeLogicalDependencies(FactHandle handle) throws FactException { + Set set = (Set) this.justified.remove( ((InternalFactHandle) handle).getId() ); + if ( set != null && !set.isEmpty() ) { + for ( Iterator it = set.iterator(); it.hasNext(); ) { + LogicalDependency node = (LogicalDependency) it.next(); + node.getJustifier().getLogicalDependencies().remove( node ); + } + } + } + public void addLogicalDependency(FactHandle handle, Activation activation, PropagationContext context, @@ -395,42 +441,55 @@ set.add( node ); } - public void removeLogicalDependencies( Activation activation, - PropagationContext context, - Rule rule ) throws FactException { - org.drools.util.LinkedList list = activation.getLogicalDependencies(); - if (list == null || list.isEmpty( )) { - return; - } - for (LogicalDependency node = (LogicalDependency) list.getFirst( ); node != null; node = (LogicalDependency) node.getNext( )) { - InternalFactHandle handle = (InternalFactHandle) node.getFactHandle( ); - Set set = (Set) this.justified.get( handle.getId( ) ); - set.remove( node ); - if (set.isEmpty( )) { - this.justified.remove( handle.getId( ) ); - retractObject( handle, - false, - true, - context.getRuleOrigin( ), - context.getActivationOrigin( ) ); + protected void propagateQueuedActions() { + if (!this.factQueue.isEmpty( )) { + for (Iterator it = this.factQueue.iterator( ); it.hasNext( );) { + WorkingMemoryAction action = (WorkingMemoryAction) it.next( ); + it.remove( ); + action.propagate( ); } } } - public void removeLogicalDependencies(FactHandle handle) throws FactException { - Set set = (Set) this.justified.remove( ((InternalFactHandle) handle).getId() ); - if ( set != null && !set.isEmpty() ) { - for ( Iterator it = set.iterator(); it.hasNext(); ) { - LogicalDependency node = (LogicalDependency) it.next(); - node.getJustifier().getLogicalDependencies().remove( node ); - } - } - } - public Lock getLock() { return this.lock; } + private interface WorkingMemoryAction { + public void propagate(); + } + + private class WorkingMemoryRetractAction implements WorkingMemoryAction { + private InternalFactHandle factHandle; + private boolean removeLogical; + private boolean updateEqualsMap; + private Rule ruleOrigin; + private Activation activationOrigin; + + + + public WorkingMemoryRetractAction(InternalFactHandle factHandle, + boolean removeLogical, + boolean updateEqualsMap, + Rule ruleOrigin, + Activation activationOrigin) { + super(); + this.factHandle = factHandle; + this.removeLogical = removeLogical; + this.updateEqualsMap = updateEqualsMap; + this.ruleOrigin = ruleOrigin; + this.activationOrigin = activationOrigin; + } + + public void propagate() { + retractObject( this.factHandle, + this.removeLogical, + this.updateEqualsMap, + this.ruleOrigin, + this.activationOrigin ); + } + } + protected static class FactStatus { private int counter; private String status; Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/FactTable.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/FactTable.java 2006-05-13 10:11:23 UTC (rev 4213) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/FactTable.java 2006-05-13 14:12:32 UTC (rev 4214) @@ -46,7 +46,7 @@ * Tuples that are either already on agenda or are very close (missing * exists or have not facts matching) */ - private final LinkedList tuples; + private LinkedList tuples; /** * initializes base LeapsTable with appropriate Comparator and positive and @@ -67,9 +67,8 @@ * @param workingMemory * @param ruleHandle */ - public void addRule(WorkingMemoryImpl workingMemory, - RuleHandle ruleHandle) { - if ( !this.rules.contains( ruleHandle ) ) { + public void addRule( WorkingMemoryImpl workingMemory, RuleHandle ruleHandle ) { + if (!this.rules.contains( ruleHandle )) { this.rules.add( ruleHandle ); // push facts back to stack if needed this.checkAndAddFactsToStack( workingMemory ); @@ -81,8 +80,18 @@ * * @param ruleHandle */ - public void removeRule(RuleHandle ruleHandle) { + public void removeRule( RuleHandle ruleHandle ) { this.rules.remove( ruleHandle ); + // remove tuples that are still there + LinkedList list = new LinkedList( ); + + for (Iterator it = this.getTuplesIterator( ); it.hasNext( );) { + LeapsTuple tuple = (LeapsTuple) it.next( ); + if (ruleHandle.getLeapsRule( ).getRule( ) != tuple.getLeapsRule( ).getRule( )) { + list.add( tuple ); + } + } + this.tuples = list; } /** Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/WorkingMemoryImpl.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/WorkingMemoryImpl.java 2006-05-13 10:11:23 UTC (rev 4213) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/WorkingMemoryImpl.java 2006-05-13 14:12:32 UTC (rev 4214) @@ -74,6 +74,8 @@ private final IdentityMap leapsRulesToHandlesMap = new IdentityMap( ); + private final IdentityMap rulesActivationsMap = new IdentityMap( ); + /** * Construct. * @@ -214,11 +216,11 @@ boolean logical, Rule rule, Activation activation ) throws FactException { - + FactHandleImpl handle ; this.getLock().lock( ); try { // check if the object already exists in the WM - FactHandleImpl handle = (FactHandleImpl) this.identityMap.get( object ); + handle = (FactHandleImpl) this.identityMap.get( object ); // lets see if the object is already logical asserted FactStatus logicalState = (FactStatus) this.equalsMap.get( object ); @@ -237,6 +239,7 @@ activation, activation.getPropagationContext( ), rule ); + return logicalState.getHandle( ); } @@ -294,7 +297,6 @@ activation, activation.getPropagationContext( ), rule ); - } // new leaps stack token @@ -380,12 +382,13 @@ } } } - - return handle; + propagateQueuedActions( ); } finally { - this.getLock().unlock( ); + this.getLock( ).unlock( ); } + + return handle; } /** @@ -555,6 +558,8 @@ activation ); this.workingMemoryEventSupport.fireObjectRetracted( context, handle, oldObject ); + + propagateQueuedActions(); } finally { this.getLock().unlock( ); @@ -586,14 +591,37 @@ } } + + + public void addLogicalDependency( FactHandle handle, + Activation activation, + PropagationContext context, + Rule rule ) throws FactException { + super.addLogicalDependency( handle, activation, context, rule ); + + LinkedList activations = (LinkedList) this.rulesActivationsMap.get( rule ); + if (activations == null) { + activations = new LinkedList( ); + this.rulesActivationsMap.put( rule, activations ); + } + activations.add( activation ); + } + + + public void removeLogicalDependencies( Activation activation, + PropagationContext context, + Rule rule ) throws FactException { + super.removeLogicalDependencies( activation, context, rule ); + } + /** * @see WorkingMemory */ - public void modifyObject(FactHandle handle, + public void modifyObject( FactHandle handle, Object object, Rule rule, Activation activation ) throws FactException { - this.getLock().lock( ); + this.getLock( ).lock( ); try { this.retractObject( handle ); @@ -624,9 +652,10 @@ handle, ( (FactHandleImpl) handle ).getObject( ), object ); + propagateQueuedActions( ); } finally { - this.getLock().unlock( ); + this.getLock( ).unlock( ); } } @@ -778,22 +807,36 @@ this.getLock( ).lock( ); try { ArrayList ruleHandlesList; - LeapsRule rule; + LeapsRule leapsRule; RuleHandle ruleHandle; for (Iterator it = rules.iterator( ); it.hasNext( );) { - rule = (LeapsRule) it.next( ); + leapsRule = (LeapsRule) it.next( ); // some times rules do not have "normal" constraints and only // not and exists - if (rule.getNumberOfColumns( ) > 0) { - ruleHandlesList = (ArrayList) this.leapsRulesToHandlesMap.remove( rule ); + if (leapsRule.getNumberOfColumns( ) > 0) { + ruleHandlesList = (ArrayList) this.leapsRulesToHandlesMap.remove( leapsRule ); for (int i = 0; i < ruleHandlesList.size( ); i++) { ruleHandle = (RuleHandle) ruleHandlesList.get( i ); // - this.getFactTable( rule.getColumnClassObjectTypeAtPosition( i ) ) + this.getFactTable( leapsRule.getColumnClassObjectTypeAtPosition( i ) ) .removeRule( ruleHandle ); } } + // } + Rule rule = ((LeapsRule)rules.get(0)).getRule( ); + List activations = (List) this.rulesActivationsMap.remove( rule ); + if (activations != null) { + for (Iterator activationsIt = activations.iterator( ); activationsIt.hasNext( );) { + Activation activation = (Activation) activationsIt.next( ); + ((LeapsTuple)activation.getTuple()).setActivation(null); + this.removeLogicalDependencies( activation, + activation.getPropagationContext( ), + rule ); + } + } + + propagateQueuedActions(); } finally { this.getLock( ).unlock( ); |
From: <jbo...@li...> - 2006-05-13 10:11:36
|
Author: mla...@jb... Date: 2006-05-13 06:11:23 -0400 (Sat, 13 May 2006) New Revision: 4213 Modified: labs/jbossweb/trunk/src/share/classes/org/apache/tomcat/util/net/AprEndpoint.java Log: Use APR_UNSPEC only if the address contains colon. Modified: labs/jbossweb/trunk/src/share/classes/org/apache/tomcat/util/net/AprEndpoint.java =================================================================== --- labs/jbossweb/trunk/src/share/classes/org/apache/tomcat/util/net/AprEndpoint.java 2006-05-13 00:27:10 UTC (rev 4212) +++ labs/jbossweb/trunk/src/share/classes/org/apache/tomcat/util/net/AprEndpoint.java 2006-05-13 10:11:23 UTC (rev 4213) @@ -553,8 +553,10 @@ addressStr = address.getHostAddress(); } int family = Socket.APR_INET; - if (Library.APR_HAVE_IPV6) - family= Socket.APR_UNSPEC; + if (Library.APR_HAVE_IPV6 && addressStr != null) { + if (addressStr.indexOf(':') >= 0) + family= Socket.APR_UNSPEC; + } long inetAddress = Address.info(addressStr, family, port, 0, rootPool); // Create the APR server socket |
Author: unibrew Date: 2006-05-12 20:27:10 -0400 (Fri, 12 May 2006) New Revision: 4212 Added: labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersService.java labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/CountersServiceInterface.java Removed: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/CountersService.java Modified: labs/jbosslabs/trunk/portal-extensions/counters-ejb3/project.xml labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersEntity.java labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersMDB.java labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersServiceBean.java labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/Counter.java labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDB.java labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDescriptor.java labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersWatcher.java labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/Sorting.java Log: [JBLAB-665] DownloadCountes are now persisted in database. Modified: labs/jbosslabs/trunk/portal-extensions/counters-ejb3/project.xml =================================================================== --- labs/jbosslabs/trunk/portal-extensions/counters-ejb3/project.xml 2006-05-12 23:02:59 UTC (rev 4211) +++ labs/jbosslabs/trunk/portal-extensions/counters-ejb3/project.xml 2006-05-13 00:27:10 UTC (rev 4212) @@ -39,6 +39,11 @@ <version></version> <jar>jboss-j2ee.jar</jar> </dependency> - + <dependency> + <groupId>jboss</groupId> + <artifactId>jboss-annotations-ejb3</artifactId> + <version></version> + <jar>jboss-annotations-ejb3.jar</jar> + </dependency> </dependencies> </project> Modified: labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersEntity.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersEntity.java 2006-05-12 23:02:59 UTC (rev 4211) +++ labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersEntity.java 2006-05-13 00:27:10 UTC (rev 4212) @@ -28,6 +28,8 @@ import javax.persistence.Id; import javax.persistence.Table; +import org.jboss.forge.common.projects.Sorting; + /** * * @author Ryszard Kozmik @@ -44,6 +46,15 @@ private String projectId; private boolean visible; + + public CountersEntity () + { + this.path = ""; + this.order = Sorting.RANDOM.toString(); + this.projectId=""; + this.visible = true; + } + public CountersEntity (String path, long initValue, String projectId, boolean visible, String order) { this.path = path; Modified: labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersMDB.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersMDB.java 2006-05-12 23:02:59 UTC (rev 4211) +++ labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersMDB.java 2006-05-13 00:27:10 UTC (rev 4212) @@ -32,7 +32,7 @@ import javax.naming.InitialContext; import javax.naming.NamingException; -import org.jboss.forge.common.projects.CountersService; +import org.jboss.forge.common.projects.CountersServiceInterface; import org.jboss.logging.Logger; @@ -69,7 +69,7 @@ TextMessage txtMsg = (TextMessage) msg; InitialContext ctx = new InitialContext(); CountersService countersService = - (CountersService) ctx.lookup(CountersService.class.getName()); + (CountersService) ctx.lookup(CountersServiceInterface.jndiName); countersService.incrementCounter(txtMsg.getText()); System.out.println("HELLO!!: "+txtMsg.getText()); } Added: labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersService.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersService.java 2006-05-12 23:02:59 UTC (rev 4211) +++ labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersService.java 2006-05-13 00:27:10 UTC (rev 4212) @@ -0,0 +1,37 @@ + + /* + * 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.counters; + +import javax.ejb.Local; + +import org.jboss.forge.common.projects.CountersServiceInterface; + + +/** + * + * @author Ryszard Kozmik + * + */ +@Local +public interface CountersService extends CountersServiceInterface {} \ No newline at end of file Modified: labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersServiceBean.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersServiceBean.java 2006-05-12 23:02:59 UTC (rev 4211) +++ labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersServiceBean.java 2006-05-13 00:27:10 UTC (rev 4212) @@ -31,8 +31,9 @@ import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; +import org.jboss.annotation.ejb.LocalBinding; import org.jboss.forge.common.projects.Counter; -import org.jboss.forge.common.projects.CountersService; +import org.jboss.forge.common.projects.CountersServiceInterface; import org.jboss.forge.common.projects.Sorting; @@ -42,6 +43,7 @@ * */ @Stateless +@LocalBinding (jndiBinding=CountersServiceInterface.jndiName) public class CountersServiceBean implements CountersService { @@ -65,10 +67,11 @@ public void updateCounters(Map<String,Counter> downloadCounters) { - + System.out.println("HELLO UPDATECOUNTERS"); synchronized (downloadCounters) { for (String path : downloadCounters.keySet()) { + System.out.println("UPDATING PATH: "+path); Counter counter = downloadCounters.get(path); CountersEntity ce = em.find(CountersEntity.class,path); if (ce==null) Modified: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/Counter.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/Counter.java 2006-05-12 23:02:59 UTC (rev 4211) +++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/Counter.java 2006-05-13 00:27:10 UTC (rev 4212) @@ -23,15 +23,17 @@ package org.jboss.forge.common.projects; +import java.io.Serializable; + /** * Each Counter class object represents simply one counter for a download link. * Object contains the current counter value and projectId for this link. - * + * * @author Ryszard Kozmik */ -public class Counter { +public class Counter implements Serializable { /** * Current value of a download counter. Deleted: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/CountersService.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/CountersService.java 2006-05-12 23:02:59 UTC (rev 4211) +++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/CountersService.java 2006-05-13 00:27:10 UTC (rev 4212) @@ -1,46 +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.common.projects; - -import java.util.Map; - -import javax.ejb.Local; - - -/** - * - * @author Ryszard Kozmik - * - */ -@Local -public interface CountersService -{ - - public Map<String,Counter> getCountersMap(); - - public void updateCounters(Map<String,Counter> downloadCounters); - - public void incrementCounter (String path); - -} Added: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/CountersServiceInterface.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/CountersServiceInterface.java 2006-05-12 23:02:59 UTC (rev 4211) +++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/CountersServiceInterface.java 2006-05-13 00:27:10 UTC (rev 4212) @@ -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.common.projects; + +import java.util.Map; + +/** + * + * @author Ryszard Kozmik + * + */ +public interface CountersServiceInterface +{ + + public static final String jndiName = "countersService/local"; + + public Map<String,Counter> getCountersMap(); + + public void updateCounters(Map<String,Counter> downloadCounters); + + public void incrementCounter (String path); + +} Modified: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDB.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDB.java 2006-05-12 23:02:59 UTC (rev 4211) +++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDB.java 2006-05-13 00:27:10 UTC (rev 4212) @@ -56,8 +56,8 @@ try { ctx = new InitialContext(); - CountersService countersService = - (CountersService) ctx.lookup(CountersService.class.getName()); + CountersServiceInterface countersService = + (CountersServiceInterface) ctx.lookup(CountersServiceInterface.jndiName); downloadCounters = countersService.getCountersMap(); // SOD @@ -74,6 +74,8 @@ // Synchronizing tracked links in downloadConters with links from // projects download counter descriptors. synchronizeCounters(descriptors); + + countersService.updateCounters(downloadCounters); // SOD @@ -107,14 +109,19 @@ try { - CountersService countersService = - (CountersService) ctx.lookup(CountersService.class.getName()); + CountersServiceInterface countersService = + (CountersServiceInterface) ctx.lookup(CountersServiceInterface.jndiName); countersService.updateCounters(downloadCounters); } catch (Exception e) { getLogger().error("Failed to persist downloadCounters", e); } + // SOD + for (String path : downloadCounters.keySet()) + { + System.out.println("SOD 4.5 Path: "+path+" Value: "+downloadCounters.get(path)); + } } /** @@ -133,9 +140,9 @@ System.out.println("DownloadCounters: "+link); try { - CountersService countersService = - (CountersService) ctx.lookup(CountersService.class.getName()); - countersService.incrementCounter(link); + //CountersServiceInterface countersService = + // (CountersServiceInterface) ctx.lookup(CountersServiceInterface.jndiName); + //countersService.incrementCounter(link); QueueSession sess = null; Queue queue = null; Modified: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDescriptor.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDescriptor.java 2006-05-12 23:02:59 UTC (rev 4211) +++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDescriptor.java 2006-05-13 00:27:10 UTC (rev 4212) @@ -246,10 +246,10 @@ } // SOD - //for (String path : downloadCounters.keySet()) - //{ - // System.out.println("SOD 3 Path: "+path+" Value: "+downloadCounters.get(path)); - // } + for (String path : downloadCounters.keySet()) + { + System.out.println("SOD 3 Path: "+path+" Value: "+downloadCounters.get(path)); + } // Iterating through projects nodes containing download counter descriptors. for (String projectId:counters.keySet()){ @@ -291,10 +291,10 @@ } // SOD - // for (String path : downloadCounters.keySet()) - // { - // System.out.println("SOD 5 Path: "+path+" Value: "+downloadCounters.get(path)); - // } + for (String path : downloadCounters.keySet()) + { + System.out.println("SOD 5 Path: "+path+" Value: "+downloadCounters.get(path)); + } // Changing status to false becouse downloadCounters Map // is now synchronized with projects' download counter descriptors. @@ -360,10 +360,20 @@ * Project id name for which the links are added. */ private synchronized void addLinksForCounting (Map<String,Boolean> links,String projectId,Sorting sorting) { + // SOD + for (String path : downloadCounters.keySet()) + { + System.out.println("SOD 10 Path: "+path+" Value: "+downloadCounters.get(path)); + } // Adding new download links for tracking. for (String link:links.keySet()) { downloadCounters.put(link,new Counter(0,projectId,links.get(link),sorting)); } + // SOD + for (String path : downloadCounters.keySet()) + { + System.out.println("SOD 11 Path: "+path+" Value: "+downloadCounters.get(path)); + } } private synchronized void removeLinksForProjects (Set<String> projects) { @@ -427,7 +437,23 @@ * Map<String,Long> containing link:value pairs. */ public synchronized Map<String,Long> getValuesForPortlet (String projectId) { + + System.out.println("GETVALUESFORPORTLET"); + System.out.println("PROJECTID: "+projectId); + // SOD + for (String path : downloadCounters.keySet()) + { + System.out.println("SOD 12 Path: "+path+" Value: "+downloadCounters.get(path)+ + " ProjectId: "+downloadCounters.get(path).getProjectId()+" Visible:"+downloadCounters.get(path).getVisible()); + } Map<String,Boolean> links = getProjectLinks(projectId); + + //SOD + for (String project : links.keySet()) + { + System.out.println("SOD: PROJECTLINK: "+project+" BOOLEAN: "+links.get(project)); + } + Map<String,Long> values = null; if (links.size()==0) { values = new Hashtable<String,Long>(0); @@ -451,7 +477,8 @@ * positive integer - when counter for the first link is greater than for second one */ public synchronized int compare(String link1, String link2) { - return (int)(downloadCounters.get(link1).getValue()-downloadCounters.get(link2).getValue()); + int valueCompare = (int)(downloadCounters.get(link1).getValue()-downloadCounters.get(link2).getValue()); + return valueCompare==0?link1.compareTo(link2):valueCompare; } }); } else if (sorting==Sorting.DESC || sorting==Sorting.DESCENDING) { @@ -469,7 +496,8 @@ * positive integer - when counter for the first link is lower than for second one */ public synchronized int compare(String link1, String link2) { - return (int)(downloadCounters.get(link2).getValue()-downloadCounters.get(link1).getValue()); + int valueCompare = (int)(downloadCounters.get(link2).getValue()-downloadCounters.get(link1).getValue()); + return valueCompare==0?link2.compareTo(link1):valueCompare; } }); } else { @@ -480,6 +508,18 @@ values.put(link,downloadCounters.get(link).getValue()); } } + + for (String link : values.keySet()) + { + System.out.println("SOD: VALUES || LINK: "+link+" LONGVAL: "+values.get(link)); + } + + // SOD + for (String path : downloadCounters.keySet()) + { + System.out.println("SOD 13 Path: "+path+" Value: "+downloadCounters.get(path).getValue() + + " ProjectId: "+downloadCounters.get(path).getProjectId()+" Visible:"+downloadCounters.get(path).getVisible()); + } return values; } Modified: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersWatcher.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersWatcher.java 2006-05-12 23:02:59 UTC (rev 4211) +++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersWatcher.java 2006-05-13 00:27:10 UTC (rev 4212) @@ -69,7 +69,7 @@ */ private Object getDescriptor (String portalName) { DownloadCountersDescriptor descriptor = - new DownloadCountersDescriptor(portalName, contentManager); + new DownloadCountersDB(portalName, contentManager); rw = new ResourceWatcher(contentManager); // Registering ResourceWatcher to watch for main download counters xml file change. //rw.watchResource(DownloadCounterTools.getMainXmlPath(portalName)); Modified: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/Sorting.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/Sorting.java 2006-05-12 23:02:59 UTC (rev 4211) +++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/Sorting.java 2006-05-13 00:27:10 UTC (rev 4212) @@ -23,12 +23,14 @@ package org.jboss.forge.common.projects; +import java.io.Serializable; + /** * This enum describes possible ways of sorting. - * + * * @author Ryszard Kozmik * */ -public enum Sorting { +public enum Sorting implements Serializable { ASCENDING,ASC,DESCENDING,DESC,RANDOM } |
From: <jbo...@li...> - 2006-05-12 23:03:10
|
Author: wrzep Date: 2006-05-12 19:02:59 -0400 (Fri, 12 May 2006) New Revision: 4211 Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/ScoresMDB.java labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/ScoresManagerAsync.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/service/model/ScoresServiceLocal.java Log: JBLAB-599 MDB for JMM 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-05-12 20:02:22 UTC (rev 4210) +++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java 2006-05-12 23:02:59 UTC (rev 4211) @@ -23,7 +23,6 @@ package org.jboss.forge.status; import java.util.ArrayList; -import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -46,6 +45,7 @@ import org.jboss.forge.status.templates.Columns; import org.jboss.forge.status.templates.MatrixTemplate; import org.jboss.forge.status.tools.ScoresManager; +import org.jboss.forge.status.tools.ScoresManagerAsync; import org.jboss.forge.status.tools.ServiceConf; import org.jboss.forge.status.tools.Tags; @@ -91,15 +91,15 @@ PluginsValues pluginsValues; try { + //<debug> + ScoresManagerAsync.init(portalName, serviceConf); + ScoresManagerAsync.save(projects, pluginsConf); + // </debug> + // Compute and save current scores ScoresManager.save(projects, pluginsConf); - // <debug>; - //long v = ScoresManager.getValue("downloads", "jbosswiki", new Date(), new Date()); - //System.out.println("value = " + v); - // </debug> - pluginsValues = ScoresManager.getCurrentScores(); } catch (ScoresSaveException e) { Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/ScoresMDB.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/ScoresMDB.java 2006-05-12 20:02:22 UTC (rev 4210) +++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/ScoresMDB.java 2006-05-12 23:02:59 UTC (rev 4211) @@ -0,0 +1,362 @@ +/* + * 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.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.ActivationConfigProperty; +import javax.ejb.MessageDriven; +import javax.jms.JMSException; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.MessageListener; + +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.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; + +/** +* @author Pawel Wrzeszcz (pawel.wrzeszcz [at] gmail.com) +*/ + +@MessageDriven(activateConfig = +{ + @ActivationConfigProperty(propertyName="destinationType", + propertyValue="javax.jms.Queue"), + @ActivationConfigProperty(propertyName="destination", + propertyValue="queue/jmm") +}) +public class ScoresMDB implements MessageListener { + + private static Logger log = Logger.getLogger(ScoresServiceImpl.class); + + private Map<String,PluginsValuesImpl> values = new HashMap<String,PluginsValuesImpl>(); + + @Inject + private ContentManager cm; + + public void onMessage(Message msg) { + + MapMessage message = (MapMessage) msg; + + try { + String request = message.getString("name"); + + System.out.println("request name: " + request); + } catch (JMSException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + } + + /** + * 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 { + + log.info("Saving..."); + + // 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); + + log.info("Computing scores..."); + + // 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; + + log.info("Getting shotoku node..."); + + 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 + * @throws ScoresSaveException + */ + private void save(Node node, PluginsValuesImpl pluginsValues) + throws ScoresSaveException { + + try { + OutputStream os = node.getOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(os); + oos.writeObject((PluginsValuesImpl) pluginsValues); + oos.close(); + node.save("update"); /* os is closed inside save() */ + log.info("Saved succesfully"); + } catch (Exception e) { + log.error("Error while saving shotoku node: " + + node.getFullName(), e); + throw new ScoresSaveException(e); + } + } + + /** + * 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 { + + log.info("Returning plugins values..."); + + // 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 + + log.info("Value not in cache..."); + 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); + log.info("Finished."); + 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); + } + +} Modified: 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-05-12 20:02:22 UTC (rev 4210) +++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/model/ScoresServiceLocal.java 2006-05-12 23:02:59 UTC (rev 4211) @@ -25,6 +25,7 @@ /** * @author Pawel Wrzeszcz (pawel.wrzeszcz [at] gmail.com) */ + public interface ScoresServiceLocal extends ScoresService { } \ No newline at end of file Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/ScoresManagerAsync.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/ScoresManagerAsync.java 2006-05-12 20:02:22 UTC (rev 4210) +++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/ScoresManagerAsync.java 2006-05-12 23:02:59 UTC (rev 4211) @@ -0,0 +1,172 @@ +/* + * 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.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import javax.jms.JMSException; +import javax.jms.MapMessage; +import javax.jms.Queue; +import javax.jms.QueueConnection; +import javax.jms.QueueConnectionFactory; +import javax.jms.QueueSender; +import javax.jms.QueueSession; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +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.PluginsValues; + +/** +* @author Pawel Wrzeszcz (pawel.wrzeszcz [at] gmail.com) +*/ + +public class ScoresManagerAsync { + + private static String portalName; + private static boolean isRemote; + private static Properties properties; + + public static void init(String portalName, ServiceConf serviceConf) { + + ScoresManagerAsync.portalName = portalName; + + isRemote = serviceConf.isRemote(); + System.out.println("remote: " + isRemote); + + properties = serviceConf.getProperties(); + } + + public static void save(Projects projects, List<PluginConf> pluginsConf) + throws ScoresSaveException { + + // Fill arguments + Map<String,Object> args = new HashMap<String,Object>(); + args.put("projects", projects); //TODO store these args names somewhere ;-) + args.put("pluginsConf", pluginsConf); + args.put("portalName", portalName); + + // Send message + try { + sendMessage("save", args); + } catch (Exception e) { + throw new ScoresSaveException(e); + } + + // TODO poll/wait for results + } + + public static PluginsValues getScores(Date date, Date toDate) + throws GetScoresException { + //TODO toDate + + + // Fill arguments + Map<String,Object> args = new HashMap<String,Object>(); + args.put("date", date); + args.put("portalName", portalName); + + // Send message + try { + sendMessage("getPluginsValues", args); + } catch (Exception e) { + throw new GetScoresException(e); + } + + // TODO poll/wait for results + + PluginsValues pluginsValues = null; + + if (pluginsValues == null) { + throw new GetScoresException(); + } + + return pluginsValues; + } + + /** + * For the specified plugin returns historical project score + * from the given <code>date</code> in the past. + * If scores from specified day are not available, + * the next available scores saved at the day before or equal + * to <code>toDate</code> are returned. + * + * Notice that only year, month and day matter in passed dates. + * + * @return project score from the given date for specified plugin + * @throws GetScoresException + */ + public static long getValue(String pluginId, String projectId, + Date date, Date toDate) + throws GetScoresException { + + PluginsValues pluginsValues = getScores(date, toDate); + + return pluginsValues.getPluginValue(pluginId, projectId); + } + + public static PluginsValues getCurrentScores() + throws GetScoresException { + + Date now = new Date(); + + return getScores(now, now); + } + + private static void sendMessage(String name, Map<String,Object> args) throws + NamingException, JMSException { + + Queue queue = null; + QueueConnection connection = null; + QueueSession session = null; + QueueSender sender = null; + Context context = new InitialContext(properties); + + queue = (Queue) context.lookup("queue/jmm"); + QueueConnectionFactory factory = + (QueueConnectionFactory) context.lookup("ConnectionFactory"); + connection = factory.createQueueConnection(); + session = connection.createQueueSession(false, + QueueSession.AUTO_ACKNOWLEDGE); + + // Copy arguments into message + MapMessage message = session.createMapMessage(); + message.setString("name", name); + for (String argName : args.keySet()) { + message.setObject(argName, args.get(argName)); + } + + sender = session.createSender(queue); + sender.send(message); + // sess.commit (); TODO closing vs committing + session.close (); + } + +} |
From: <jbo...@li...> - 2006-05-12 20:02:27
|
Author: mar...@jb... Date: 2006-05-12 16:02:22 -0400 (Fri, 12 May 2006) New Revision: 4210 Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/WorkingMemoryImpl.java Log: -Moved return outside try.. finally block. Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/WorkingMemoryImpl.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/WorkingMemoryImpl.java 2006-05-12 16:43:04 UTC (rev 4209) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/WorkingMemoryImpl.java 2006-05-12 20:02:22 UTC (rev 4210) @@ -439,11 +439,12 @@ boolean logical, Rule rule, Activation activation) throws FactException { + FactHandleImpl handle = null; this.lock.lock(); try { // check if the object already exists in the WM - FactHandleImpl handle = (FactHandleImpl) this.identityMap.get( object ); + handle = (FactHandleImpl) this.identityMap.get( object ); // lets see if the object is already logical asserted FactStatus logicalState = (FactStatus) this.equalsMap.get( object ); @@ -535,12 +536,11 @@ if ( !this.factQueue.isEmpty() ) { propagateQueuedActions(); - } - - return handle; + } } finally { this.lock.unlock(); } + return handle; } private void addPropertyChangeListener(Object object) { |
Author: szimano Date: 2006-05-12 12:43:04 -0400 (Fri, 12 May 2006) New Revision: 4209 Added: labs/jbosslabs/trunk/portal-extensions/forge-portal-attr/src/java/org/jboss/forge/portal/CharResponseWrapper.java labs/jbosslabs/trunk/portal-extensions/forge-portal-attr/src/java/org/jboss/forge/portal/TitleChangeFilter.java labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/management/NotificationMsg.java labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-management/src/java/org/jboss/wiki/MailNotificationBean.java Modified: labs/jbosslabs/trunk/portal-extensions/configuration/to-copy/jboss-portal.sar/portal-server.war/WEB-INF/web.xml labs/jbosslabs/trunk/portal-extensions/forge-root-redirect/src/web/WEB-INF/web.xml labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/WikiCommon.java labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/WikiEngine.java labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-management/project.xml Log: msb sources JBWIKI-87 Modified: labs/jbosslabs/trunk/portal-extensions/configuration/to-copy/jboss-portal.sar/portal-server.war/WEB-INF/web.xml =================================================================== --- labs/jbosslabs/trunk/portal-extensions/configuration/to-copy/jboss-portal.sar/portal-server.war/WEB-INF/web.xml 2006-05-12 12:55:53 UTC (rev 4208) +++ labs/jbosslabs/trunk/portal-extensions/configuration/to-copy/jboss-portal.sar/portal-server.war/WEB-INF/web.xml 2006-05-12 16:43:04 UTC (rev 4209) @@ -11,8 +11,17 @@ --> - <!-- LABS FILTERS --> - + <!-- LABS FILTERS --> + <filter> + <filter-name>titleAndTimestampFilter</filter-name> + <filter-class>org.jboss.forge.portal.TitleChangeFilter</filter-class> + </filter> + + <filter-mapping> + <filter-name>titleAndTimestampFilter</filter-name> + <url-pattern>/*</url-pattern> + </filter-mapping> + <!-- SSL Processor --> <filter> <filter-name>SSLProcessor</filter-name> Added: labs/jbosslabs/trunk/portal-extensions/forge-portal-attr/src/java/org/jboss/forge/portal/CharResponseWrapper.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-portal-attr/src/java/org/jboss/forge/portal/CharResponseWrapper.java 2006-05-12 12:55:53 UTC (rev 4208) +++ labs/jbosslabs/trunk/portal-extensions/forge-portal-attr/src/java/org/jboss/forge/portal/CharResponseWrapper.java 2006-05-12 16:43:04 UTC (rev 4209) @@ -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.portal; + +import java.io.CharArrayWriter; +import java.io.PrintWriter; + +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpServletResponseWrapper; + +public class CharResponseWrapper extends HttpServletResponseWrapper { + private CharArrayWriter output; + + public String toString() { + return output.toString(); + } + + public CharResponseWrapper(HttpServletResponse response) { + super(response); + output = new CharArrayWriter(); + } + + public PrintWriter getWriter() { + return new PrintWriter(output); + } +} Added: labs/jbosslabs/trunk/portal-extensions/forge-portal-attr/src/java/org/jboss/forge/portal/TitleChangeFilter.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-portal-attr/src/java/org/jboss/forge/portal/TitleChangeFilter.java 2006-05-12 12:55:53 UTC (rev 4208) +++ labs/jbosslabs/trunk/portal-extensions/forge-portal-attr/src/java/org/jboss/forge/portal/TitleChangeFilter.java 2006-05-12 16:43:04 UTC (rev 4209) @@ -0,0 +1,137 @@ +/* + * 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.portal; + +import java.io.IOException; +import java.io.PrintWriter; + +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.jboss.shotoku.ContentManager; +import org.jboss.shotoku.Node; +import org.jboss.shotoku.exceptions.RepositoryException; +import org.jboss.shotoku.exceptions.ResourceDoesNotExist; + +public class TitleChangeFilter implements Filter { + + private static final String TITLE_START_TAG = "<title>"; + + private static final String TITLE_END_TAG = "</title>"; + + private static final String PORTAL_CONTEXT = "/portal/"; + + private static final String SHOT_PREF = "/default/members/"; + + private static final String FREEZONE = "/freezone"; + + public void init(FilterConfig conf) throws ServletException { + + } + + public void doFilter(ServletRequest request, ServletResponse response, + FilterChain chain) throws IOException, ServletException { + + HttpServletResponse hResp = (HttpServletResponse) response; + HttpServletRequest hReq = (HttpServletRequest)request; + + String uri = hReq.getRequestURI(); + + setTimestamp(uri, hResp); + + CharResponseWrapper wrapper = new CharResponseWrapper( + (HttpServletResponse) response); + chain.doFilter(request, wrapper); + + if (wrapper.getContentType().startsWith("text/html")) { + + PrintWriter out = response.getWriter(); + + out.write(changePageTitle(wrapper.toString())); + + out.close(); + } + } + + private void setTimestamp(String uri, HttpServletResponse resp) { + if (uri.startsWith(PORTAL_CONTEXT)) { + uri = uri.substring(PORTAL_CONTEXT.length()); + + if (uri.indexOf('/') != -1) { + StringBuffer uriBuffer = new StringBuffer(uri); + uriBuffer.insert(uri.indexOf('/'), FREEZONE); + + uriBuffer.insert(0, SHOT_PREF); + + uri = uriBuffer.toString(); + + try { + Node node = ContentManager.getContentManager().getNode(uri); + + resp.setDateHeader("Last-Modified", node.getLastModification()); + } catch (RepositoryException e) { + e.printStackTrace(); + } catch (ResourceDoesNotExist e) { + //it's not a shotoku element. ignore. + } + } + } + } + + public void destroy() { + + } + + private String changePageTitle(String content) { + String pageContent = content.toLowerCase(); + + int titleIndx = pageContent.indexOf(TITLE_START_TAG); + int titleEnd = pageContent.indexOf(TITLE_END_TAG, titleIndx); + + if (titleIndx != -1) { + int titleToUse; + int endOfTitleTag; + + if ((titleToUse = pageContent.indexOf(TITLE_START_TAG, + titleIndx + 1)) != -1 + && (endOfTitleTag = pageContent.indexOf(TITLE_END_TAG, + titleToUse + 1)) != -1 && titleEnd != endOfTitleTag) { + return content.substring(0, titleIndx + + TITLE_START_TAG.length()) + + content.substring(titleToUse + + TITLE_START_TAG.length(), endOfTitleTag) + + content.substring(titleEnd, + content.length() - 1); + } else { + return content; + } + } else { + return content; + } + } +} Modified: labs/jbosslabs/trunk/portal-extensions/forge-root-redirect/src/web/WEB-INF/web.xml =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-root-redirect/src/web/WEB-INF/web.xml 2006-05-12 12:55:53 UTC (rev 4208) +++ labs/jbosslabs/trunk/portal-extensions/forge-root-redirect/src/web/WEB-INF/web.xml 2006-05-12 16:43:04 UTC (rev 4209) @@ -13,4 +13,5 @@ <url-pattern>/*</url-pattern> <dispatcher>REQUEST</dispatcher> </filter-mapping> + </web-app> \ No newline at end of file Modified: labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/WikiCommon.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/WikiCommon.java 2006-05-12 12:55:53 UTC (rev 4208) +++ labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/WikiCommon.java 2006-05-12 16:43:04 UTC (rev 4209) @@ -21,9 +21,23 @@ */ package org.jboss.wiki; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; +import java.util.TreeSet; + +import javax.jms.ObjectMessage; +import javax.jms.Queue; +import javax.jms.QueueConnectionFactory; +import javax.jms.QueueSession; +import javax.naming.InitialContext; +import javax.naming.NamingException; + +import org.jboss.logging.Logger; import org.jboss.mx.util.MBeanProxyExt; import org.jboss.mx.util.MBeanServerLocator; import org.jboss.wiki.exceptions.WikiManagementNotFoundException; +import org.jboss.wiki.management.NotificationMsg; import org.jboss.wiki.management.WikiServiceMenagement; public class WikiCommon { @@ -32,9 +46,11 @@ public static final String WIKI_SERVICE_NAME = "wiki:service=wikiService"; - private WikiServiceMenagement wikiServiceMenagement; + private static Logger log = Logger.getLogger(WikiCommon.class); + + private static WikiServiceMenagement wikiServiceMenagement; - public WikiServiceMenagement getWikiManagement() throws WikiManagementNotFoundException{ + public static WikiServiceMenagement getWikiManagement() throws WikiManagementNotFoundException{ try { if (wikiServiceMenagement == null) wikiServiceMenagement = (WikiServiceMenagement) MBeanProxyExt.create( @@ -47,4 +63,66 @@ throw new WikiManagementNotFoundException(e); } } + + public static void sendNotificationMail(WikiPage page) { + try { + InitialContext context = new InitialContext(); + + QueueSession sess = null; + Queue queue = null; + try { + queue = (Queue) context.lookup("queue/mdb"); + QueueConnectionFactory factory = (QueueConnectionFactory) context + .lookup("ConnectionFactory"); + sess = factory.createQueueConnection().createQueueSession( + false, QueueSession.AUTO_ACKNOWLEDGE); + + if (sess != null) { + + String notifs = page.getMetaDataProperty("notifications"); + + if (notifs != null) { + Set<String> emails = new TreeSet<String>(); + String[] splitedMails = notifs.split(";"); + + for (int i = 0; i < splitedMails.length; i++) { + emails.add(splitedMails[i]); + } + + page = (WikiPage) page.clone(); + WikiEngine engine = getWikiManagement().getWikiEngine(); + page = engine.getWikiType("htmlClear").process(page, new WikiSession(){ + + private Map<String, Object> attributes = new TreeMap<String, Object>(); + public Object getAttribute(String attributeName) { + return attributes.get(attributeName); + } + + public void setAttribute(String attributeName, Object attribute) { + attributes.put(attributeName, attribute); + } + + public void removeAttribute(String attributeName) { + attributes.remove(attributeName); + } + + public String getId() { + return this.toString(); + }}); + + NotificationMsg notifMsg = new NotificationMsg(emails, page.getContent(), page.getName()); + ObjectMessage msg = sess.createObjectMessage(notifMsg); + sess.createSender(queue).send(msg); + } + } + else { + log.error("Couldn't create queue session."); + } + } catch (Exception e) { + log.error(e); + } + } catch (NamingException e1) { + log.error(e1); + } + } } Modified: labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/WikiEngine.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/WikiEngine.java 2006-05-12 12:55:53 UTC (rev 4208) +++ labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/WikiEngine.java 2006-05-12 16:43:04 UTC (rev 4209) @@ -893,6 +893,11 @@ } postSave(langCode); + + // send notifications + page.setMetaDataProperty("notifications", "sz...@as..."); + log.info("sending notif"); + WikiCommon.sendNotificationMail(page); } Added: labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/management/NotificationMsg.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/management/NotificationMsg.java 2006-05-12 12:55:53 UTC (rev 4208) +++ labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/management/NotificationMsg.java 2006-05-12 16:43:04 UTC (rev 4209) @@ -0,0 +1,70 @@ +/* + * 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.wiki.management; + +import java.io.Serializable; +import java.util.Set; + +public class NotificationMsg implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 1L; + + private Set<String> emails; + + private String pageContent; + + private String pageName; + + public NotificationMsg(Set<String> emails, String pageContent, String pageName) { + this.emails = emails; + this.pageContent = pageContent; + this.pageName = pageName; + } + + public Set<String> getEmails() { + return emails; + } + + public void setEmails(Set<String> emails) { + this.emails = emails; + } + + public String getPageContent() { + return pageContent; + } + + public void setPageContent(String pageContent) { + this.pageContent = pageContent; + } + + public String getPageName() { + return pageName; + } + + public void setPageName(String pageName) { + this.pageName = pageName; + } + +} Modified: labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-management/project.xml =================================================================== --- labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-management/project.xml 2006-05-12 12:55:53 UTC (rev 4208) +++ labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-management/project.xml 2006-05-12 16:43:04 UTC (rev 4209) @@ -33,12 +33,11 @@ </organization> <dependencies> - - <dependency> - <groupId>aslibs</groupId> - <artifactId>javax.servlet</artifactId> + <dependency> + <groupId>jboss</groupId> + <artifactId>jboss-j2ee</artifactId> <version>1.0</version> - <jar>javax.servlet.jar</jar> + <jar>jboss-j2ee.jar</jar> </dependency> <dependency> @@ -52,10 +51,10 @@ </dependency> <dependency> - <groupId>aslibs</groupId> - <artifactId>javax.servlet.jsp</artifactId> + <groupId>jboss</groupId> + <artifactId>jboss-mail</artifactId> <version>1.0</version> - <jar>javax.servlet.jsp.jar</jar> + <jar>mail.jar</jar> </dependency> <dependency> @@ -99,23 +98,19 @@ </dependency> <dependency> - <groupId>jboss</groupId> - <artifactId>jboss-annotations-ejb3</artifactId> - <version>1.0</version> - <jar>jboss-annotations-ejb3.jar</jar> - </dependency> - - <dependency> - <id>portlet-api</id> - <version>1.0</version> + <groupId>jboss</groupId> + <artifactId>jboss-annotations-ejb3</artifactId> + <version>1.0</version> + <jar>jboss-annotations-ejb3.jar</jar> </dependency> + <dependency> - <groupId>jboss</groupId> - <artifactId>jboss-jmx</artifactId> - <version>1.0</version> - <jar>jboss-jmx.jar</jar> - </dependency> + <groupId>jboss</groupId> + <artifactId>jboss-jmx</artifactId> + <version>1.0</version> + <jar>jboss-jmx.jar</jar> + </dependency> <dependency> <groupId>jboss</groupId> @@ -144,5 +139,6 @@ <version>1.0</version> <jar>portal-portlet-lib.jar</jar> </dependency> + </dependencies> </project> Added: labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-management/src/java/org/jboss/wiki/MailNotificationBean.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-management/src/java/org/jboss/wiki/MailNotificationBean.java 2006-05-12 12:55:53 UTC (rev 4208) +++ labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-management/src/java/org/jboss/wiki/MailNotificationBean.java 2006-05-12 16:43:04 UTC (rev 4209) @@ -0,0 +1,107 @@ +/* + * 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.wiki; + +import java.util.Date; + +import javax.jms.Message; +import javax.jms.MessageListener; +import javax.jms.ObjectMessage; +import javax.mail.Address; +import javax.mail.Session; +import javax.mail.Transport; +import javax.mail.Message.RecipientType; +import javax.mail.internet.InternetAddress; +import javax.mail.internet.MimeMessage; +import javax.naming.InitialContext; +import javax.rmi.PortableRemoteObject; +import javax.ejb.MessageDriven; + +import org.jboss.logging.Logger; +import org.jboss.wiki.management.NotificationMsg; + +public @MessageDriven(activateConfig = { + @javax.ejb.ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"), + @javax.ejb.ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/mdb") }) +class MailNotificationBean implements MessageListener { + + private final static String EMAIL_ADDRESS = "sz...@o2..."; + + private Logger log = Logger.getLogger(this.getClass()); + + public void onMessage(Message msg) { + + log.info("Mail"); + + try { + + ObjectMessage omsg = (ObjectMessage) msg; + Session session = null; + + try { + session = (Session) PortableRemoteObject + .narrow(new InitialContext().lookup("java:Mail"), + Session.class); + try { + if (omsg.getObject() instanceof NotificationMsg) { + NotificationMsg notifications = (NotificationMsg) omsg + .getObject(); + + log.info("Got email notification msg"); + + for (String email : notifications.getEmails()) { + log.info("MDB for: " + email); + + StringBuffer buffer = null; + Address[] to = null; + MimeMessage m = new MimeMessage(session); + + if (email != null) { + m.setFrom(new InternetAddress(EMAIL_ADDRESS)); + to = new InternetAddress[] { new InternetAddress( + email) }; + m.setRecipients(RecipientType.TO, to); + m.setSubject("[JBossWiki] Page change notification: " + notifications.getPageName()); + + m.setSentDate(new Date()); + buffer = new StringBuffer(); + + buffer.append("This message is generated automaticcaly. Please do not reply. To remove yourself from the watch list please go to www.\n\n"); + buffer.append(notifications.getPageContent()); + + m.setContent(buffer.toString(), "text/html; charset=\"UTF-8\""); + Transport.send(m); + } + } + } + } catch (javax.mail.MessagingException e) { + log.error(e); + } + } catch (javax.naming.NamingException e) { + log.error(e); + } + } catch (Exception e) { + log.error(e); + } + + } +} |
Author: tirelli Date: 2006-05-12 08:55:53 -0400 (Fri, 12 May 2006) New Revision: 4208 Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_LogicalAssertionsDynamicRule.drl labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_LogicalAssertionsDynamicRule2.drl labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/AlphaNode.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectTypeNode.java Log: Fixing JBRULES-267 - rule removal inconsistency Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java 2006-05-12 12:01:35 UTC (rev 4207) +++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java 2006-05-12 12:55:53 UTC (rev 4208) @@ -1497,6 +1497,10 @@ ruleBase.removeRule( "org.drools.test", "like cheese" ); + Cheese muzzarela = new Cheese( "muzzarela", + 5 ); + workingMemory.assertObject( muzzarela ); + assertEquals( 4, workingMemory.getAgenda().getActivations().length ); Modified: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_LogicalAssertionsDynamicRule.drl =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_LogicalAssertionsDynamicRule.drl 2006-05-12 12:01:35 UTC (rev 4207) +++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_LogicalAssertionsDynamicRule.drl 2006-05-12 12:55:53 UTC (rev 4208) @@ -4,8 +4,8 @@ rule "rule1" when - #Cheese( type : type, price : price -> (price.intValue() > 1)) - Cheese( type : type, price > 1 ) + Cheese( type : type, price : price -> (price.intValue() > 1)) + #Cheese( type : type, price > 1 ) then assertLogical( type ); end Modified: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_LogicalAssertionsDynamicRule2.drl =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_LogicalAssertionsDynamicRule2.drl 2006-05-12 12:01:35 UTC (rev 4207) +++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_LogicalAssertionsDynamicRule2.drl 2006-05-12 12:55:53 UTC (rev 4208) @@ -4,8 +4,8 @@ rule "rule2" when - #Cheese( type : type, price : price -> (price.intValue() < 3)) - Cheese( type : type, price < 3) + Cheese( type : type, price : price -> (price.intValue() < 3)) + #Cheese( type : type, price < 3) then assertLogical( type ); end \ No newline at end of file Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/AlphaNode.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/AlphaNode.java 2006-05-12 12:01:35 UTC (rev 4207) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/AlphaNode.java 2006-05-12 12:55:53 UTC (rev 4208) @@ -204,7 +204,7 @@ public void remove(BaseNode node, WorkingMemoryImpl[] workingMemories) { - getObjectSinks().remove( node ); + this.objectSinks.remove( (ObjectSink) node ); removeShare(); if ( this.sharedCount < 0 ) { for ( int i = 0, length = workingMemories.length; i < length; i++ ) { Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectTypeNode.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectTypeNode.java 2006-05-12 12:01:35 UTC (rev 4207) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectTypeNode.java 2006-05-12 12:55:53 UTC (rev 4208) @@ -214,7 +214,7 @@ public void remove(BaseNode node, WorkingMemoryImpl[] workingMemories) { - getObjectSinks().remove( node ); + this.objectSinks.remove( (ObjectSink) node ); removeShare(); if ( this.sharedCount < 0 ) { for ( int i = 0, length = workingMemories.length; i < length; i++ ) { |
From: <jbo...@li...> - 2006-05-12 12:01:48
|
Author: tirelli Date: 2006-05-12 08:01:35 -0400 (Fri, 12 May 2006) New Revision: 4207 Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/EvalConditionNode.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/LeftInputAdapterNode.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/NotNode.java Log: Renaming variables to follow standard naming convention Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/EvalConditionNode.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/EvalConditionNode.java 2006-05-12 09:30:30 UTC (rev 4206) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/EvalConditionNode.java 2006-05-12 12:01:35 UTC (rev 4207) @@ -265,7 +265,7 @@ LinkedList linkedTuples = leftTuple.getLinkedTuples(); LinkedListObjectWrapper wrapper = (LinkedListObjectWrapper) linkedTuples.getFirst(); - for( int c = 0; c < index; c++) { + for( int i = 0; i < index; i++) { wrapper = (LinkedListObjectWrapper) wrapper.getNext(); } propagatedTuples.add( wrapper.getObject() ); Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/LeftInputAdapterNode.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/LeftInputAdapterNode.java 2006-05-12 09:30:30 UTC (rev 4206) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/LeftInputAdapterNode.java 2006-05-12 12:01:35 UTC (rev 4207) @@ -313,10 +313,10 @@ int index = this.getTupleSinks().indexOf( sink ); List propagatedTuples = new ArrayList(); - for( Iterator i = memory.values().iterator(); i.hasNext(); ) { - LinkedList tuples = (LinkedList) i.next(); + for( Iterator it = memory.values().iterator(); it.hasNext(); ) { + LinkedList tuples = (LinkedList) it.next(); LinkedListObjectWrapper wrapper = (LinkedListObjectWrapper) tuples.getFirst(); - for( int c = 0; c < index; c++) { + for( int i = 0; i < index; i++) { wrapper = (LinkedListObjectWrapper) wrapper.getNext(); } propagatedTuples.add( wrapper.getObject() ); Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/NotNode.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/NotNode.java 2006-05-12 09:30:30 UTC (rev 4206) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/NotNode.java 2006-05-12 12:01:35 UTC (rev 4207) @@ -383,7 +383,7 @@ LinkedList linkedTuples = leftTuple.getLinkedTuples(); LinkedListObjectWrapper wrapper = (LinkedListObjectWrapper) linkedTuples.getFirst(); - for( int c = 0; c < index; c++) { + for( int i = 0; i < index; i++) { wrapper = (LinkedListObjectWrapper) wrapper.getNext(); } propagatedTuples.add( wrapper.getObject() ); |
From: <jbo...@li...> - 2006-05-12 09:30:35
|
Author: mic...@jb... Date: 2006-05-12 05:30:30 -0400 (Fri, 12 May 2006) New Revision: 4206 Modified: labs/jbossrules/trunk/drools-ide/src/main/java/org/drools/ide/editors/keywords.properties Log: added new back in Modified: labs/jbossrules/trunk/drools-ide/src/main/java/org/drools/ide/editors/keywords.properties =================================================================== --- labs/jbossrules/trunk/drools-ide/src/main/java/org/drools/ide/editors/keywords.properties 2006-05-12 09:30:03 UTC (rev 4205) +++ labs/jbossrules/trunk/drools-ide/src/main/java/org/drools/ide/editors/keywords.properties 2006-05-12 09:30:30 UTC (rev 4206) @@ -22,3 +22,4 @@ not auto-focus xor-group +new |
From: <jbo...@li...> - 2006-05-12 09:30:08
|
Author: mic...@jb... Date: 2006-05-12 05:30:03 -0400 (Fri, 12 May 2006) New Revision: 4205 Modified: labs/jbossrules/trunk/documentation/manual/en/Chapter-Rule_Language/Section-DSL.xml Log: new deployment section Modified: labs/jbossrules/trunk/documentation/manual/en/Chapter-Rule_Language/Section-DSL.xml =================================================================== --- labs/jbossrules/trunk/documentation/manual/en/Chapter-Rule_Language/Section-DSL.xml 2006-05-12 09:29:47 UTC (rev 4204) +++ labs/jbossrules/trunk/documentation/manual/en/Chapter-Rule_Language/Section-DSL.xml 2006-05-12 09:30:03 UTC (rev 4205) @@ -24,10 +24,16 @@ <para>DSLs have no impact on the rules at runtime, they are just a parse/compile time feature.</para> + + <para>Note that Drools 3 DSLs are quite different from Drools 2 XML based + DSLs. It is still possible to do Drools 2 style XML languages - if you + require this, then take a look at the Drools 3 XML rule language, and + consider using XSLT to map from your XML language to the Drools 3 XML + language.</para> </section> <section> - <title>Creating and editing a DSL</title> + <title>Editing and managing a DSL</title> <para>A DSL's configuration like most things is stored in plain text. If you use the IDE, you get a nice graphical editor (with some validation), @@ -89,8 +95,8 @@ <para>The "{" and "}" characters should only be used on the left hand side of the mapping (the expression) to mark tokens. On the right hand side you - can use "{" and "}" on their own if needed (such as if (foo) { - doSomething(); } ) as well as with the token names as shown above.</para> + can use "{" and "}" on their own if needed - such as <programlisting>if (foo) { + doSomething(); }</programlisting> as well as with the token names as shown above.</para> <para>Don't forget that if you are capturing strings from users, you will also need the quotes on the right hand side of the mapping, just like a @@ -198,4 +204,52 @@ Expander and ExpanderResolver interfaces, it is possible to plug in your own advanced expanders if required.</para> </section> + + <section> + <title>Creating a DSL from scratch</title> + <para> + DSLs can be aid with capturing rules if the rules are well known, just not in any technically usable format (ie. sitting around in people brains). + Until we are able to have those little sockets in our necks like in the Matrix, our means of getting stuff into computers is still the old fashioned way. + </para> + <para> + Rules engines require a object or data model to operate on - in many cases you may know this up front. In othercases the model will be discovered with the rules. + In any case, rules generally work better with simpler flatter object models. In some cases, this may mean having a rule object model which is a subset of the main applications model (perhaps mapped from it). Object models can often have complex relationships and hierachies in them - for rules you will want to simplify and flatten the model where possible, and let the rule engine infer relationships (as it provides future flexibility). + As stated previously, DSLs can have an advantage of providing some insulation between the object model and the rule language. + </para> + <para> + Coming up with a DSL is a collaborative approach for both technical and domain experts. Historically there was a role called "knowledge engineer" which is someone skilled in both the rule technology, and in capturing rules. Overa short period of time, your DSL should stabilise, which means that changes to rules are done entirely using the DSL. + A suggested approach if you are starting from scratch is the following workflow: + + <itemizedlist> + <listitem> + <para>Capture rules as loose "if then" statements - this is really to get an idea of size and complexity (possibly in a text document).</para> + </listitem> + + <listitem> + <para>Look for recurring statements in the rules captured. Also look for the rule objects/fields (and match them up with what may already be known of the object model).</para> + </listitem> + + <listitem> + <para>Create a new DSL, and start adding statements from the above steps. Provide the "holes" for data to be edited (as many statements will be similar, with only some data changing).</para> + </listitem> + + <listitem> + <para>Use the above DSL, and try to write the rules just like that appear in the "if then" statements from the first and second steps. Iterate this process until patterns appear and things stabilise. At this stage, you are not so worried about the rule language underneath, just the DSL.</para> + </listitem> + + <listitem> + <para>At this stage you will need to look at the Objects, and the Fields that are needed for the rules, reconcile this with the datamodel so far.</para> + </listitem> + + <listitem> + <para>Map the DSL statements to the rule language, based on the object model. Then repeat the process. Obviously this is best done in small steps, to make sure that things are on the right track.</para> + </listitem> + </itemizedlist> + </para> + + <para> + A challanging concept to express in DSLs is bound variables. A tip for this is to have a DSL expressions that just bind a given variable name to an Object Type (with no conditions - you can add conditions to that bound object type in subsequent statements). You can then use that name elsewhere in the DSL (including in the action part of the rule). + </para> + + </section> </section> \ No newline at end of file |