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-06-21 18:50:34
|
Author: dam...@jb... Date: 2006-06-21 14:50:32 -0400 (Wed, 21 Jun 2006) New Revision: 4797 Modified: labs/jbosslabs/branches/prod/jbosslabs/portal-extensions/ Log: Set shotoku to use prod branch external. Property changes on: labs/jbosslabs/branches/prod/jbosslabs/portal-extensions ___________________________________________________________________ Name: svn:externals - shotoku http://anonsvn.labs.jboss.com/labs/shotoku/branches/qa + shotoku http://anonsvn.labs.jboss.com/labs/shotoku/branches/prod |
Author: dam...@jb... Date: 2006-06-21 14:48:28 -0400 (Wed, 21 Jun 2006) New Revision: 4796 Added: labs/shotoku/branches/prod/shotoku-base/src/java/org/jboss/shotoku/service/Null.java Modified: labs/shotoku/branches/prod/shotoku-admin/src/web/WEB-INF/web.xml labs/shotoku/branches/prod/shotoku-aop/src/java/org/jboss/shotoku/aop/CacheInjectAspect.java labs/shotoku/branches/prod/shotoku-base/src/java/org/jboss/shotoku/service/ShotokuServiceImpl.java labs/shotoku/branches/prod/shotoku-base/src/java/org/jboss/shotoku/tools/Pair.java labs/shotoku/branches/prod/shotoku-base/src/java/org/jboss/shotoku/tools/Triple.java labs/shotoku/branches/prod/shotoku-file-access/src/java/org/jboss/shotoku/fileaccess/FileAccessServlet.java labs/shotoku/branches/prod/shotoku-tags/src/java/org/jboss/shotoku/tags/AbstractTag.java labs/shotoku/branches/prod/shotoku-tags/src/java/org/jboss/shotoku/tags/service/TagServiceImpl.java Log: MERGED: r 4784:4794 https://svn.labs.jboss.com/labs/shotoku/branches/qa into prod shotoku for Labs 1.1-SP1 release. Modified: labs/shotoku/branches/prod/shotoku-admin/src/web/WEB-INF/web.xml =================================================================== --- labs/shotoku/branches/prod/shotoku-admin/src/web/WEB-INF/web.xml 2006-06-21 18:48:03 UTC (rev 4795) +++ labs/shotoku/branches/prod/shotoku-admin/src/web/WEB-INF/web.xml 2006-06-21 18:48:28 UTC (rev 4796) @@ -47,7 +47,7 @@ <security-constraint> <web-resource-collection> <web-resource-name>All resources</web-resource-name> - <url-pattern>/admin/*</url-pattern> + <url-pattern>/*</url-pattern> </web-resource-collection> <auth-constraint> <role-name>ShotokuAdmin</role-name> Modified: labs/shotoku/branches/prod/shotoku-aop/src/java/org/jboss/shotoku/aop/CacheInjectAspect.java =================================================================== --- labs/shotoku/branches/prod/shotoku-aop/src/java/org/jboss/shotoku/aop/CacheInjectAspect.java 2006-06-21 18:48:03 UTC (rev 4795) +++ labs/shotoku/branches/prod/shotoku-aop/src/java/org/jboss/shotoku/aop/CacheInjectAspect.java 2006-06-21 18:48:28 UTC (rev 4796) @@ -32,30 +32,35 @@ */ @Aspect(scope=Scope.PER_JOINPOINT) public class CacheInjectAspect { - ShotokuCacheItem sci; + private final static Object synchronizer = new Object(); + private ShotokuCacheItem sci; private CacheItem getCurrentAnnotation(FieldInvocation invocation) { - CacheItem current = invocation.getField().getAnnotation(CacheItem.class); - if (current == null) - throw new RuntimeException("This aspect should be used only with " + - "@CacheItem!"); + CacheItem current = invocation.getField().getAnnotation(CacheItem.class); + if (current == null) + throw new RuntimeException("This aspect should be used only with " + + "@CacheItem!"); - return current; - } + return current; + } @Bind(pointcut="field($instanceof{org.jboss.shotoku.cache.ShotokuCacheItem} " + "*->@org.jboss.shotoku.aop.CacheItem)") public Object accessCacheItem(FieldReadInvocation invocation) throws Throwable { if (sci == null) { - CacheItem ci = getCurrentAnnotation(invocation); + synchronized(synchronizer) { + if (sci == null) { + CacheItem ci = getCurrentAnnotation(invocation); - if (ci.interval() == 0) { - sci = (ShotokuCacheItem) - invocation.getField().getType().getConstructor().newInstance(); - } else { - sci = (ShotokuCacheItem) - invocation.getField().getType().getConstructor(Long.TYPE).newInstance( - ci.interval()); + if (ci.interval() == 0) { + sci = (ShotokuCacheItem) + invocation.getField().getType().getConstructor().newInstance(); + } else { + sci = (ShotokuCacheItem) + invocation.getField().getType().getConstructor(Long.TYPE).newInstance( + ci.interval()); + } + } } } Copied: labs/shotoku/branches/prod/shotoku-base/src/java/org/jboss/shotoku/service/Null.java (from rev 4794, labs/shotoku/branches/qa/shotoku-base/src/java/org/jboss/shotoku/service/Null.java) Modified: labs/shotoku/branches/prod/shotoku-base/src/java/org/jboss/shotoku/service/ShotokuServiceImpl.java =================================================================== --- labs/shotoku/branches/prod/shotoku-base/src/java/org/jboss/shotoku/service/ShotokuServiceImpl.java 2006-06-21 18:48:03 UTC (rev 4795) +++ labs/shotoku/branches/prod/shotoku-base/src/java/org/jboss/shotoku/service/ShotokuServiceImpl.java 2006-06-21 18:48:28 UTC (rev 4796) @@ -130,11 +130,20 @@ new ConcurrentHashSet<ShotokuCacheItem>(); public Object get(Object key) { - return cache.get(key); + Object ret = cache.get(key); + if (Null.getInstance().equals(ret)) { + return null; + } else { + return ret; + } } public void put(Object key, Object o) { - cache.put(key, o); + if (o == null) { + cache.put(key, Null.getInstance()); + } else { + cache.put(key, o); + } } public void remove(Object key) { @@ -183,7 +192,21 @@ } public String getServiceDescription() { - return "Cache service."; + StringBuffer sb = new StringBuffer("Cache service.<br />"); + sb.append("Currently storing ").append(cache.size()).append(" items in the cache "); + sb.append("and ").append(cacheItems.size()).append(" ShotokuCacheItem objects.<br />"); + sb.append("Objects in cache:<br />"); + for (Object key : cache.keySet()) { + sb.append(key.toString()).append(" : ").append( + cache.get(key).getClass().getName()).append("<br />"); + } + + sb.append("Cache items:<br />"); + for (ShotokuCacheItem sci : cacheItems) { + sb.append(sci.getClass().getName()).append("<br />"); + } + + return sb.toString(); } /* Modified: labs/shotoku/branches/prod/shotoku-base/src/java/org/jboss/shotoku/tools/Pair.java =================================================================== --- labs/shotoku/branches/prod/shotoku-base/src/java/org/jboss/shotoku/tools/Pair.java 2006-06-21 18:48:03 UTC (rev 4795) +++ labs/shotoku/branches/prod/shotoku-base/src/java/org/jboss/shotoku/tools/Pair.java 2006-06-21 18:48:28 UTC (rev 4796) @@ -56,4 +56,8 @@ public int hashCode() { return obj1.hashCode() + obj2.hashCode(); } + + public String toString() { + return "(" + obj1.toString() + ", " + obj2.toString() + ")"; + } } Modified: labs/shotoku/branches/prod/shotoku-base/src/java/org/jboss/shotoku/tools/Triple.java =================================================================== --- labs/shotoku/branches/prod/shotoku-base/src/java/org/jboss/shotoku/tools/Triple.java 2006-06-21 18:48:03 UTC (rev 4795) +++ labs/shotoku/branches/prod/shotoku-base/src/java/org/jboss/shotoku/tools/Triple.java 2006-06-21 18:48:28 UTC (rev 4796) @@ -43,4 +43,8 @@ public int hashCode() { return obj1.hashCode() + obj2.hashCode() + obj3.hashCode(); } + + public String toString() { + return "(" + obj1.toString() + ", " + obj2.toString()+ ", " + obj3.toString() + ")"; + } } Modified: labs/shotoku/branches/prod/shotoku-file-access/src/java/org/jboss/shotoku/fileaccess/FileAccessServlet.java =================================================================== --- labs/shotoku/branches/prod/shotoku-file-access/src/java/org/jboss/shotoku/fileaccess/FileAccessServlet.java 2006-06-21 18:48:03 UTC (rev 4795) +++ labs/shotoku/branches/prod/shotoku-file-access/src/java/org/jboss/shotoku/fileaccess/FileAccessServlet.java 2006-06-21 18:48:28 UTC (rev 4796) @@ -49,7 +49,7 @@ private void writeErrorMessage(HttpServletResponse response) throws IOException { response.setContentType("text/html"); - response.getWriter().println(FileAccessServlet.ACCESS_DENIED); + response.getOutputStream().println(FileAccessServlet.ACCESS_DENIED); } protected void doGet(HttpServletRequest request, HttpServletResponse response) @@ -105,8 +105,11 @@ try { Tools.transfer(ci.getIs(), os); } finally { - os.close(); - ci.getIs().close(); + try { + os.close(); + } finally { + ci.getIs().close(); + } } } catch (Exception e) { log.info("Unable to send a file.", e); Modified: labs/shotoku/branches/prod/shotoku-tags/src/java/org/jboss/shotoku/tags/AbstractTag.java =================================================================== --- labs/shotoku/branches/prod/shotoku-tags/src/java/org/jboss/shotoku/tags/AbstractTag.java 2006-06-21 18:48:03 UTC (rev 4795) +++ labs/shotoku/branches/prod/shotoku-tags/src/java/org/jboss/shotoku/tags/AbstractTag.java 2006-06-21 18:48:28 UTC (rev 4796) @@ -8,43 +8,64 @@ * @author Adam Warski (ad...@as...) */ public abstract class AbstractTag implements Tag { - private String name; - private String author; - private String resourceId; - private String data; + private String name; - private Date dateCreated; + private String author; - public AbstractTag(String name, String author, String resourceId, - String data, Date dateCreated) { - this.name = name; - this.author = author; - this.resourceId = resourceId; - this.data = data; - this.dateCreated = dateCreated; - } + private String resourceId; - /* - * TAG implementation. - */ + private String data; - public String getName() { - return name; - } + private Date dateCreated; - public String getAuthor() { - return author; - } + public AbstractTag(String name, String author, String resourceId, + String data, Date dateCreated) { + this.name = name; + this.author = author; + this.resourceId = resourceId; + this.data = data; + this.dateCreated = dateCreated; + } - public String getResourceId() { - return resourceId; - } + /* + * TAG implementation. + */ - public String getData() { - return data; - } + public String getName() { + return name; + } - public Date getDateCreated() { - return dateCreated; - } -} + public String getAuthor() { + return author; + } + + public String getResourceId() { + return resourceId; + } + + public String getData() { + return data; + } + + public Date getDateCreated() { + return dateCreated; + } + +public boolean equals(Object obj) { + if (obj == null) { + return false; + } + + if (obj.getClass().equals(this.getClass())) { + AbstractTag otherTag = (AbstractTag) obj; + + if (name.equals(otherTag.getName()) + && ((data == null && otherTag.getData() == null) || (data != null && data.equals(otherTag.getData()))) + && resourceId.equals(otherTag.getResourceId()) + && author.equals(otherTag.getAuthor())) { + return true; + } + } + + return false; + }} Modified: labs/shotoku/branches/prod/shotoku-tags/src/java/org/jboss/shotoku/tags/service/TagServiceImpl.java =================================================================== --- labs/shotoku/branches/prod/shotoku-tags/src/java/org/jboss/shotoku/tags/service/TagServiceImpl.java 2006-06-21 18:48:03 UTC (rev 4795) +++ labs/shotoku/branches/prod/shotoku-tags/src/java/org/jboss/shotoku/tags/service/TagServiceImpl.java 2006-06-21 18:48:28 UTC (rev 4796) @@ -22,9 +22,11 @@ package org.jboss.shotoku.tags.service; import java.util.Calendar; +import java.util.HashMap; import java.util.List; import java.util.ArrayList; import java.util.Iterator; +import java.util.Map; import java.net.URLEncoder; import java.io.UnsupportedEncodingException; @@ -54,246 +56,310 @@ * @author Adam Warski (ad...@as...) * @author Damon Sicore (da...@si...) */ -@Service(objectName=org.jboss.shotoku.tags.tools.Constants.TAG_SERVICE_NAME) +@Service(objectName = org.jboss.shotoku.tags.tools.Constants.TAG_SERVICE_NAME) @Local(TagServiceLocal.class) @Management(TagService.class) @Depends(Constants.SHOTOKU_SERVICE_NAME) -public class TagServiceImpl extends AdministratedServiceImpl - implements TagService, TagServiceLocal { - private static final Logger log = Logger.getLogger(TagService.class); +public class TagServiceImpl extends AdministratedServiceImpl implements + TagService, TagServiceLocal { + private static final Logger log = Logger.getLogger(TagService.class); - /* - * Service lifecycle management. - */ + /* + * Service lifecycle management. + */ - public void create() throws Exception { - super.create(); + public void create() throws Exception { + super.create(); - // Enabling administration for this service. - Tools.getService().addAdministratedService(new AdministratedServiceGetter() { - public AdministratedService getService() { - return TagTools.getService(); - } - }); + // Enabling administration for this service. + Tools.getService().addAdministratedService( + new AdministratedServiceGetter() { + public AdministratedService getService() { + return TagTools.getService(); + } + }); - setTimerInterval(10000); + setTimerInterval(10000); - log.info("Tag service created."); - } + log.info("Tag service created."); + } - public void start() throws Exception { - super.start(); + public void start() throws Exception { + super.start(); - // Starting the updater thread. - new Thread() { - { - setDaemon(true); - } + // Starting the updater thread. + new Thread() { + { + setDaemon(true); + } - public void run() { - while (getServiceRunnable()) { - try { - sleep(getTimerInterval()); - } catch (InterruptedException e) { - e.printStackTrace(); - } + public void run() { + while (getServiceRunnable()) { + try { + sleep(getTimerInterval()); + } catch (InterruptedException e) { + e.printStackTrace(); + } - try { - update(); - } catch (Throwable t) { - // Making sure that an exception won't stop the thread. - } + try { + update(); + } catch (Throwable t) { + // Making sure that an exception won't stop the thread. + } - setLastUpdate(Calendar.getInstance().getTimeInMillis()); - } + setLastUpdate(Calendar.getInstance().getTimeInMillis()); + } - log.info("Tag service deaemon thread terminated."); - } - }.start(); + log.info("Tag service deaemon thread terminated."); + } + }.start(); - log.info("Tag service started with update interval: "+ getTimerInterval()); - } + log.info("Tag service started with update interval: " + + getTimerInterval()); + } - public void stop() { - super.stop(); - log.info("Tag service signaled to stop."); - } + public void stop() { + super.stop(); + log.info("Tag service signaled to stop."); + } - public void destroy() { - } + public void destroy() { + } - /* - * Timer-handling functions. - */ + /* + * Timer-handling functions. + */ - public void update() { + public void update() { - } + } - public String getServiceId() { - return "ShotokuTagService"; - } + public String getServiceId() { + return "ShotokuTagService"; + } - public String getServiceName() { - return "Tag service"; - } + public String getServiceName() { + return "Tag service"; + } - public String getServiceDescription() { - return "Shotoku tag service"; - } + public String getServiceDescription() { + return "Shotoku tag service"; + } - /* - * TagService implementation. - */ + /* + * TagService implementation. + */ - @PersistenceContext - private EntityManager manager; + @PersistenceContext + private EntityManager manager; - private TagEntity getTagEntity(Tag t) { - TagEntity te = new TagEntity(); + /** + * MIN_SIMILARITY - minimal similarity for checking relatedTags needed + */ + private double MIN_SIMILARITY = 0.7d; - te.setAuthor(t.getAuthor()); - te.setData(t.getData()); - te.setDateCreated(t.getDateCreated()); - te.setName(t.getName()); - te.setResourceId(t.getResourceId()); - te.setType(t.getType()); + private TagEntity getTagEntity(Tag t) { + TagEntity te = new TagEntity(); - return te; - } + te.setAuthor(t.getAuthor()); + te.setData(t.getData()); + te.setDateCreated(t.getDateCreated()); + te.setName(t.getName()); + te.setResourceId(t.getResourceId()); + te.setType(t.getType()); - public void addTag(Tag t) throws TagAddException { - try { - manager.persist(getTagEntity(t)); - } catch (Throwable e) { - throw new TagAddException(e); - } - } + return te; + } - public void deleteTag(Tag t) throws TagDeleteException { - try { - manager.remove(getTagEntity(t)); - } catch (Throwable e) { - throw new TagDeleteException(e); - } - } + public void addTag(Tag t) throws TagAddException { + try { + manager.persist(getTagEntity(t)); + } catch (Throwable e) { + throw new TagAddException(e); + } + } - public List<Tag> getTags(String resourceId) throws TagGetException { - try { - //noinspection unchecked - List<TagEntity> result = manager.createQuery( - "from TagEntity where resourceId = :resourceId order by dateCreated desc"). - setParameter("resourceId", resourceId).getResultList(); + public void deleteTag(Tag t) throws TagDeleteException { + try { + manager.remove(getTagEntity(t)); + } catch (Throwable e) { + throw new TagDeleteException(e); + } + } - List<Tag> ret = new ArrayList<Tag>(); - for (TagEntity te : result) { - ret.add(te.getTag()); - } + public List<Tag> getTags(String resourceId) throws TagGetException { + try { + // noinspection unchecked + List<TagEntity> result = manager + .createQuery( + "from TagEntity where resourceId = :resourceId order by dateCreated desc") + .setParameter("resourceId", resourceId).getResultList(); - return ret; - } catch (Throwable e) { - throw new TagGetException(e); - } - } + List<Tag> ret = new ArrayList<Tag>(); + for (TagEntity te : result) { + ret.add(te.getTag()); + } - public Tag getTag(String tagName) throws TagGetException { - try { - //noinspection unchecked - TagEntity result = (TagEntity) manager.createQuery("from TagEntity where name = :name"). - setParameter("name", tagName).getSingleResult(); + return ret; + } catch (Throwable e) { + throw new TagGetException(e); + } + } - if (result == null) { - return null; - } + public Tag getTag(String tagName) throws TagGetException { + try { + // noinspection unchecked + TagEntity result = (TagEntity) manager.createQuery( + "from TagEntity where name = :name").setParameter("name", + tagName).getSingleResult(); - return result.getTag(); - } catch (Throwable e) { - throw new TagGetException(e); - } - } + if (result == null) { + return null; + } - public List<Tag> getTags(List<String> tagNames) throws TagGetException { - try { - StringBuffer querySb = new StringBuffer("from TagEntity where "); - int i = 0; - for (Iterator iter = tagNames.iterator(); iter.hasNext();) { - querySb.append("name").append(" = :name").append(i); + return result.getTag(); + } catch (Throwable e) { + throw new TagGetException(e); + } + } - iter.next(); + public List<Tag> getTags(List<String> tagNames) throws TagGetException { + try { + StringBuffer querySb = new StringBuffer("from TagEntity where "); + int i = 0; + for (Iterator iter = tagNames.iterator(); iter.hasNext();) { + querySb.append("name").append(" = :name").append(i); - if (iter.hasNext()) { - querySb.append(" and "); - } + iter.next(); - i++; - } + if (iter.hasNext()) { + querySb.append(" and "); + } - Query query = manager.createQuery(querySb.toString()); - i = 0; - for (String tagName : tagNames) { - query.setParameter("name" + i++, tagName); - } + i++; + } - //noinspection unchecked - List<TagEntity> result = query.getResultList(); + Query query = manager.createQuery(querySb.toString()); + i = 0; + for (String tagName : tagNames) { + query.setParameter("name" + i++, tagName); + } - List<Tag> ret = new ArrayList<Tag>(); - for (TagEntity te : result) { - ret.add(te.getTag()); - } + // noinspection unchecked + List<TagEntity> result = query.getResultList(); - return ret; - } catch (Throwable e) { - throw new TagGetException(e); - } - } + List<Tag> ret = new ArrayList<Tag>(); + for (TagEntity te : result) { + ret.add(te.getTag()); + } - public List<Tag> getRelatedTags(List<Tag> relateTo) throws TagGetException { - return null; - } + return ret; + } catch (Throwable e) { + throw new TagGetException(e); + } + } - public List<Tag> getTagsByAuthor(String author) throws TagGetException { - try { - //noinspection unchecked - List<TagEntity> result = manager.createQuery( - "from TagEntity where author = :author order by dateCreated desc"). - setParameter("author", author).getResultList(); + public List<Tag> getRelatedTags(List<Tag> relateTo) throws TagGetException { + List<Tag> ret = new ArrayList<Tag>(); - List<Tag> ret = new ArrayList<Tag>(); - for (TagEntity te : result) { - ret.add(te.getTag()); - } + Map<String, List<Tag>> otherResources = new HashMap<String, List<Tag>>(); - return ret; - } catch (Throwable e) { - throw new TagGetException(e); - } - } + for (Tag relatedTag : relateTo) { + List<TagEntity> result = manager.createQuery( + "from TagEntity where name = :name").setParameter("name", + relatedTag.getName()).getResultList(); - public String getFeedLink(FeedType feedType, String data, String type) { - try { - return "/feeds/tag/" + feedType.toString() + "/" + - URLEncoder.encode(data, "UTF-8") + "/" + type; - } catch (UnsupportedEncodingException e) { - return ""; - } - } + for (TagEntity otherTag : result) { + if (!otherResources.containsKey(otherTag.getResourceId())) { + otherResources.put(otherTag.getResourceId(), + getTags(otherTag.getResourceId())); + } + } + } - public String getFeedLink(FeedType feedType, List<String> dataList, String type) { - StringBuffer sb = new StringBuffer(); + for (List<Tag> tagList : otherResources.values()) { + if (checkSimilarity(relateTo, tagList) >= MIN_SIMILARITY) { + ret.addAll(tagList); + } + } - for (Iterator<String> iter = dataList.iterator(); iter.hasNext();) { - sb.append(iter.next()); - if (iter.hasNext()) { - sb.append("+"); - } - } + // don't return "relateTo" members + List<Tag> endRet = new ArrayList<Tag>(ret); + for (Tag tag : ret) { + if (tagListContainsTag(tag, relateTo)) { + endRet.remove(tag); + } + } + + return endRet; + } + + private boolean tagListContainsTag(Tag tag, List<Tag> listToCheck) { + for (Tag tag2 : listToCheck) { + if (tag.getName().equals(tag2.getName())) { + return true; + } + } + + return false; + } - try { - return "/feeds/tag/" + feedType.toString() + "/" + - URLEncoder.encode(sb.toString(), "UTF-8") + "/" + type; - } catch (UnsupportedEncodingException e) { - return ""; - } - } + private double checkSimilarity(List<Tag> givenTags, List<Tag> listToCheck) { + double ret = 0; + + for (Tag tag : givenTags) { + if (tagListContainsTag(tag,listToCheck)) { + ret++; + } + } + + return ret / (double) givenTags.size(); + } + + public List<Tag> getTagsByAuthor(String author) throws TagGetException { + try { + // noinspection unchecked + List<TagEntity> result = manager + .createQuery( + "from TagEntity where author = :author order by dateCreated desc") + .setParameter("author", author).getResultList(); + + List<Tag> ret = new ArrayList<Tag>(); + for (TagEntity te : result) { + ret.add(te.getTag()); + } + + return ret; + } catch (Throwable e) { + throw new TagGetException(e); + } + } + + public String getFeedLink(FeedType feedType, String data, String type) { + try { + return "/feeds/tag/" + feedType.toString() + "/" + + URLEncoder.encode(data, "UTF-8") + "/" + type; + } catch (UnsupportedEncodingException e) { + return ""; + } + } + + public String getFeedLink(FeedType feedType, List<String> dataList, + String type) { + StringBuffer sb = new StringBuffer(); + + for (Iterator<String> iter = dataList.iterator(); iter.hasNext();) { + sb.append(iter.next()); + if (iter.hasNext()) { + sb.append("+"); + } + } + + try { + return "/feeds/tag/" + feedType.toString() + "/" + + URLEncoder.encode(sb.toString(), "UTF-8") + "/" + type; + } catch (UnsupportedEncodingException e) { + return ""; + } + } } |
From: <jbo...@li...> - 2006-06-21 18:48:07
|
Author: dam...@jb... Date: 2006-06-21 14:48:03 -0400 (Wed, 21 Jun 2006) New Revision: 4795 Added: labs/shotoku/tags/Shotoku-Labs-1.1/ Log: Labeling for Labs 1.1 release. Copied: labs/shotoku/tags/Shotoku-Labs-1.1 (from rev 4794, labs/shotoku/branches/prod) |
From: <jbo...@li...> - 2006-06-21 18:39:55
|
Author: dam...@jb... Date: 2006-06-21 14:39:53 -0400 (Wed, 21 Jun 2006) New Revision: 4794 Added: labs/jbosslabs/branches/prod/ Log: Branching QA for Labs 1.1-SP1 promote. Copied: labs/jbosslabs/branches/prod (from rev 4793, labs/jbosslabs/branches/qa) |
From: <jbo...@li...> - 2006-06-21 18:39:29
|
Author: dam...@jb... Date: 2006-06-21 14:39:27 -0400 (Wed, 21 Jun 2006) New Revision: 4793 Removed: labs/jbosslabs/branches/prod/ Log: Removing prod branch only to copy from QA for Labs 1.1-SP1 promote. |
From: <jbo...@li...> - 2006-06-21 18:38:10
|
Author: dam...@jb... Date: 2006-06-21 14:38:08 -0400 (Wed, 21 Jun 2006) New Revision: 4792 Added: labs/jbosslabs/tags/JBossLabs-1.1/ Log: Tagging JBoss Labs 1.1 from prod branch. Copied: labs/jbosslabs/tags/JBossLabs-1.1 (from rev 4791, labs/jbosslabs/branches/prod) |
From: <jbo...@li...> - 2006-06-21 07:43:24
|
Author: mic...@jb... Date: 2006-06-21 03:43:18 -0400 (Wed, 21 Jun 2006) New Revision: 4791 Modified: labs/jbossrules/trunk/documentation/training/developers-course/Module 4 - Rule Engine Concepts 2.odp Log: Modified: labs/jbossrules/trunk/documentation/training/developers-course/Module 4 - Rule Engine Concepts 2.odp =================================================================== (Binary files differ) |
Author: mic...@jb... Date: 2006-06-21 00:17:31 -0400 (Wed, 21 Jun 2006) New Revision: 4790 Added: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/LineBasedExpander.java labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/lang/dsl/ labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/lang/dsl/rule1.drl labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/lang/dsl/LineExpanderTest.java Log: JBRULES-268 Added: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/LineBasedExpander.java =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/LineBasedExpander.java 2006-06-21 00:52:41 UTC (rev 4789) +++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/LineBasedExpander.java 2006-06-21 04:17:31 UTC (rev 4790) @@ -0,0 +1,178 @@ +package org.drools.lang.dsl; + +import java.util.StringTokenizer; + +import org.drools.lang.Expander; + +/** + * This is a simple line based expander front end for the DRL parser. + * Kind of a micro parser in itself. + * This tries to keep the whitespace and lines intact, but it is not + * guaranteed to preserve the exact spacing or line numbers. + * + * TODO: To replace the in-parser implementation in 3.1 + + * + * @author Michael Neale + */ +public class LineBasedExpander { + + private String source; + private StringBuffer output = new StringBuffer(); + private boolean lhs; + private boolean rhs; + private int lineNumber = 0; + private Expander expander; + + /** Pass in the unexpanded rule(s), and and the expander to apply */ + public LineBasedExpander(String rawSource, + Expander exp) { + source = rawSource; + this.expander = exp; + } + + /** + * This will apply the expander. And return the result. + */ + public String expand() { + StringTokenizer st = new StringTokenizer( source, + "\r\n" ); + + while ( st.hasMoreTokens() ) { + lineNumber++; + String raw = st.nextToken(); + String line = raw.trim(); + + if ( matchesKeyword( "when", + line ) ) { + lhs(); + appendLine( raw ); + } else if ( matchesKeyword( "then", + line ) ) { + rhs(); + appendLine( raw ); + } else if ( matchesKeyword( "end", + line ) ) { + endRule(); + appendLine( raw ); + output.append( "\n" ); + } else if ( matchesKeyword( "query", + line ) ) { + query(); + appendLine( raw ); + } else { + consume( raw ); + } + } + return output.toString(); + + } + + private void appendLine(String raw) { + output.append( raw ); + output.append( "\n" ); + } + + /** + * @return The expanded rule(s). + */ + public String getExpanded() { + return output.toString(); + } + + private void consume(String raw) { + if ( lhs ) { + appendLine( expand( "when", + raw ) ); + } else if ( rhs ) { + appendLine( expand( "then", + raw ) ); + } else { + appendLine( raw ); + + } + + } + + private String expand(String scope, + String raw) { + String trimmed = raw.trim(); + + if ( trimmed.startsWith( ">" ) ) { + return raw.substring( 1 ); + } else { + return "\t\t" + //some space to make it look purrty + expander.expand( scope, + normaliseSpaces( raw ) ); + } + } + + /** + * This will match the token, ignoring any single line comments. + */ + boolean matchesKeyword(String token, + String line) { + if ( line.length() < token.length() ) return false; + if ( !line.startsWith( token ) ) return false; + + String rest = line.substring( token.length() ).trim(); + + if ( rest.length() == 0 ) return true; + char next = rest.charAt( 0 ); + if ( next == '#' || next == '/' ) { + return true; + } else { + return false; + } + + } + + /** + * This will normalise all spaces (no 2 spaces in a row). + * Strings (single or double quoted) are left alone. + */ + String normaliseSpaces(String original) { + + boolean singleQ = false; + boolean doubleQ = false; + boolean prevSpace = false; + + StringBuffer buf = new StringBuffer(); + char[] cs = original.trim().toCharArray(); + for ( int i = 0; i < cs.length; i++ ) { + char c = cs[i]; + if ( Character.isWhitespace( c ) && !(singleQ || doubleQ) ) { + if ( !prevSpace ) { + buf.append( ' ' ); + prevSpace = true; + } + } else { + prevSpace = false; + if ( c == '\'' ) singleQ = !singleQ; + if ( c == '\"' ) doubleQ = !doubleQ; + buf.append( c ); + } + } + return buf.toString(); + } + + private void query() { + lhs(); + } + + private void endRule() { + this.lhs = false; + this.rhs = false; + + } + + private void rhs() { + this.rhs = true; + this.lhs = false; + + } + + private void lhs() { + this.lhs = true; + } + +} Property changes on: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/LineBasedExpander.java ___________________________________________________________________ Name: svn:eol-style + native Added: labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/lang/dsl/rule1.drl =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/lang/dsl/rule1.drl 2006-06-21 00:52:41 UTC (rev 4789) +++ labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/lang/dsl/rule1.drl 2006-06-21 04:17:31 UTC (rev 4790) @@ -0,0 +1,12 @@ +package foo + +expander foo + +rule "new rule" + activation-group "boo" + when + line 1 + line 2 + then + line 3 +end Property changes on: labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/lang/dsl/rule1.drl ___________________________________________________________________ Name: svn:eol-style + native Added: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/lang/dsl/LineExpanderTest.java =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/lang/dsl/LineExpanderTest.java 2006-06-21 00:52:41 UTC (rev 4789) +++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/lang/dsl/LineExpanderTest.java 2006-06-21 04:17:31 UTC (rev 4790) @@ -0,0 +1,103 @@ +package org.drools.lang.dsl; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; + +import org.drools.lang.Expander; + +import junit.framework.Assert; +import junit.framework.TestCase; + +public class LineExpanderTest extends TestCase { + + + private String readFile(String name) throws Exception { + + final InputStream in = getClass().getResourceAsStream( name ); + + final InputStreamReader reader = new InputStreamReader( in ); + + final StringBuffer text = new StringBuffer(); + + final char[] buf = new char[1024]; + int len = 0; + + while ( (len = reader.read( buf )) >= 0 ) { + text.append( buf, + 0, + len ); + } + return text.toString(); + } + + public void testFile() throws Exception { + Expander exp = new Expander() { + + public String expand(String scope, + String pattern) { + if (scope.equals( "when" )) { + if (!( + (pattern.trim().equals( "line 1" )) + || + (pattern.trim().equals( "line 2" )) + )) { + Assert.fail( "expected line 1 or line 2 only." ); + + } + } + if (scope.equals("then")) { + Assert.assertEquals( "line 3", pattern.trim() ); + } + return "expanded: " + pattern.trim(); + + } + + }; + LineBasedExpander ex = new LineBasedExpander(readFile("rule1.drl"), exp); + String result = ex.expand(); + assertNotNull(result); + System.out.println(result); + assertTrue(result.indexOf( "expanded: line 1" ) > result.indexOf( "when" )); + assertTrue(result.indexOf( "expanded: line 2" ) > result.indexOf( "expanded: line 1" )); + assertTrue(result.indexOf( "then" ) > result.indexOf( "expanded: line 2" )); + assertTrue(result.indexOf( "expanded: line 3" ) > result.indexOf( "then" )); + + + } + + public void testMatchingStart() { + LineBasedExpander exp = new LineBasedExpander("blah", null); + String when = "when"; + String end = "end"; + assertTrue(exp.matchesKeyword( when, " when".trim() )); + assertTrue(exp.matchesKeyword( when, "\twhen#foo".trim() )); + assertFalse(exp.matchesKeyword( when, "\tlwhen#foo".trim() )); + assertTrue(exp.matchesKeyword( when, "when".trim() )); + assertTrue(exp.matchesKeyword( end, "end".trim() )); + + assertTrue(exp.matchesKeyword( end, "\nend //comment".trim() )); + assertTrue(exp.matchesKeyword( end, "end//comment".trim() )); + + assertFalse(exp.matchesKeyword( end, "\n\"end\" //comment".trim() )); + assertFalse(exp.matchesKeyword( end, "\nkend//comment".trim() )); + assertFalse(exp.matchesKeyword( when, "\nend".trim() )); + assertFalse(exp.matchesKeyword( end, "\nkend//comment".trim() )); + } + + public void testNormaliseSpaces() { + String test = " this has more spaces, then is \t necessary"; + String res = "this has more spaces, then is necessary"; + + LineBasedExpander ex = new LineBasedExpander("ignore", null); + assertEquals(res, ex.normaliseSpaces( test )); + + assertEquals(">yeah", ex.normaliseSpaces( ">yeah" )); + assertEquals("yeah man", ex.normaliseSpaces( "yeah man" )); + + assertEquals("'with ' some \"\tquotes\"", + ex.normaliseSpaces( "'with ' some \"\tquotes\" " )); + + } + +} Property changes on: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/lang/dsl/LineExpanderTest.java ___________________________________________________________________ Name: svn:eol-style + native |
From: <jbo...@li...> - 2006-06-21 00:52:51
|
Author: mic...@jb... Date: 2006-06-20 20:52:41 -0400 (Tue, 20 Jun 2006) New Revision: 4789 Modified: labs/jbossrules/trunk/documentation/training/developers-course/Module 4 - Rule Engine Concepts 2.odp Log: a start Modified: labs/jbossrules/trunk/documentation/training/developers-course/Module 4 - Rule Engine Concepts 2.odp =================================================================== (Binary files differ) |
From: <jbo...@li...> - 2006-06-20 23:27:03
|
Author: szimano Date: 2006-06-20 19:26:59 -0400 (Tue, 20 Jun 2006) New Revision: 4788 Modified: labs/jbosslabs/trunk/portal-extensions/forge-tagme/src/java/org/jboss/labs/tagme/gwt/client/TagMeShowPopupListener.java Log: search basics JBLAB-704 Modified: labs/jbosslabs/trunk/portal-extensions/forge-tagme/src/java/org/jboss/labs/tagme/gwt/client/TagMeShowPopupListener.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-tagme/src/java/org/jboss/labs/tagme/gwt/client/TagMeShowPopupListener.java 2006-06-20 19:41:11 UTC (rev 4787) +++ labs/jbosslabs/trunk/portal-extensions/forge-tagme/src/java/org/jboss/labs/tagme/gwt/client/TagMeShowPopupListener.java 2006-06-20 23:26:59 UTC (rev 4788) @@ -39,6 +39,7 @@ import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.Image; import com.google.gwt.user.client.ui.Label; +import com.google.gwt.user.client.ui.TabPanel; import com.google.gwt.user.client.ui.TextBox; import com.google.gwt.user.client.ui.VerticalPanel; import com.google.gwt.user.client.ui.Widget; @@ -254,8 +255,33 @@ // popUp.show(); - dialog.add(panel); + TabPanel tabs = new TabPanel(); + tabs.add(panel, "Tag Content"); + + VerticalPanel searchPanel = new VerticalPanel(); + searchPanel.add(new Label("Search for tagged content by tag name, author or keyword search of the description")); + searchPanel.add(new Label("Tag")); + searchPanel.add(new TextBox()); + searchPanel.add(new Label("Author")); + searchPanel.add(new TextBox()); + searchPanel.add(new Label("Keyword")); + searchPanel.add(new TextBox()); + + searchPanel.add(new Label("Search results")); + searchPanel.add(new Button("Close", new ClickListener() { + public void onClick(Widget sender) { + dialog.hide(); + } + + })); + + tabs.add(searchPanel, "Tag Search"); + + tabs.selectTab(0); + + dialog.add(tabs); + dialog.setStyleName(TAGME_STYLE); dialog.setText("TagMe!"); |
Author: dam...@jb... Date: 2006-06-20 15:41:11 -0400 (Tue, 20 Jun 2006) New Revision: 4787 Added: labs/shotoku/branches/qa/shotoku-base/src/java/org/jboss/shotoku/service/Null.java Modified: labs/shotoku/branches/qa/shotoku-admin/src/web/WEB-INF/web.xml labs/shotoku/branches/qa/shotoku-aop/src/java/org/jboss/shotoku/aop/CacheInjectAspect.java labs/shotoku/branches/qa/shotoku-base/src/java/org/jboss/shotoku/service/ShotokuServiceImpl.java labs/shotoku/branches/qa/shotoku-base/src/java/org/jboss/shotoku/tools/Pair.java labs/shotoku/branches/qa/shotoku-base/src/java/org/jboss/shotoku/tools/Triple.java labs/shotoku/branches/qa/shotoku-file-access/src/java/org/jboss/shotoku/fileaccess/FileAccessServlet.java labs/shotoku/branches/qa/shotoku-tags/src/java/org/jboss/shotoku/tags/AbstractTag.java labs/shotoku/branches/qa/shotoku-tags/src/java/org/jboss/shotoku/tags/service/TagServiceImpl.java Log: MERGED: -r 4714:4786 https://svn.labs.jboss.com/labs/shotoku/trunk into qa for Labs 1.1-SP1 testing. Modified: labs/shotoku/branches/qa/shotoku-admin/src/web/WEB-INF/web.xml =================================================================== --- labs/shotoku/branches/qa/shotoku-admin/src/web/WEB-INF/web.xml 2006-06-20 19:38:10 UTC (rev 4786) +++ labs/shotoku/branches/qa/shotoku-admin/src/web/WEB-INF/web.xml 2006-06-20 19:41:11 UTC (rev 4787) @@ -47,7 +47,7 @@ <security-constraint> <web-resource-collection> <web-resource-name>All resources</web-resource-name> - <url-pattern>/admin/*</url-pattern> + <url-pattern>/*</url-pattern> </web-resource-collection> <auth-constraint> <role-name>ShotokuAdmin</role-name> Modified: labs/shotoku/branches/qa/shotoku-aop/src/java/org/jboss/shotoku/aop/CacheInjectAspect.java =================================================================== --- labs/shotoku/branches/qa/shotoku-aop/src/java/org/jboss/shotoku/aop/CacheInjectAspect.java 2006-06-20 19:38:10 UTC (rev 4786) +++ labs/shotoku/branches/qa/shotoku-aop/src/java/org/jboss/shotoku/aop/CacheInjectAspect.java 2006-06-20 19:41:11 UTC (rev 4787) @@ -32,30 +32,35 @@ */ @Aspect(scope=Scope.PER_JOINPOINT) public class CacheInjectAspect { - ShotokuCacheItem sci; + private final static Object synchronizer = new Object(); + private ShotokuCacheItem sci; private CacheItem getCurrentAnnotation(FieldInvocation invocation) { - CacheItem current = invocation.getField().getAnnotation(CacheItem.class); - if (current == null) - throw new RuntimeException("This aspect should be used only with " + - "@CacheItem!"); + CacheItem current = invocation.getField().getAnnotation(CacheItem.class); + if (current == null) + throw new RuntimeException("This aspect should be used only with " + + "@CacheItem!"); - return current; - } + return current; + } @Bind(pointcut="field($instanceof{org.jboss.shotoku.cache.ShotokuCacheItem} " + "*->@org.jboss.shotoku.aop.CacheItem)") public Object accessCacheItem(FieldReadInvocation invocation) throws Throwable { if (sci == null) { - CacheItem ci = getCurrentAnnotation(invocation); + synchronized(synchronizer) { + if (sci == null) { + CacheItem ci = getCurrentAnnotation(invocation); - if (ci.interval() == 0) { - sci = (ShotokuCacheItem) - invocation.getField().getType().getConstructor().newInstance(); - } else { - sci = (ShotokuCacheItem) - invocation.getField().getType().getConstructor(Long.TYPE).newInstance( - ci.interval()); + if (ci.interval() == 0) { + sci = (ShotokuCacheItem) + invocation.getField().getType().getConstructor().newInstance(); + } else { + sci = (ShotokuCacheItem) + invocation.getField().getType().getConstructor(Long.TYPE).newInstance( + ci.interval()); + } + } } } Copied: labs/shotoku/branches/qa/shotoku-base/src/java/org/jboss/shotoku/service/Null.java (from rev 4786, labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/service/Null.java) Modified: labs/shotoku/branches/qa/shotoku-base/src/java/org/jboss/shotoku/service/ShotokuServiceImpl.java =================================================================== --- labs/shotoku/branches/qa/shotoku-base/src/java/org/jboss/shotoku/service/ShotokuServiceImpl.java 2006-06-20 19:38:10 UTC (rev 4786) +++ labs/shotoku/branches/qa/shotoku-base/src/java/org/jboss/shotoku/service/ShotokuServiceImpl.java 2006-06-20 19:41:11 UTC (rev 4787) @@ -130,11 +130,20 @@ new ConcurrentHashSet<ShotokuCacheItem>(); public Object get(Object key) { - return cache.get(key); + Object ret = cache.get(key); + if (Null.getInstance().equals(ret)) { + return null; + } else { + return ret; + } } public void put(Object key, Object o) { - cache.put(key, o); + if (o == null) { + cache.put(key, Null.getInstance()); + } else { + cache.put(key, o); + } } public void remove(Object key) { @@ -183,7 +192,21 @@ } public String getServiceDescription() { - return "Cache service."; + StringBuffer sb = new StringBuffer("Cache service.<br />"); + sb.append("Currently storing ").append(cache.size()).append(" items in the cache "); + sb.append("and ").append(cacheItems.size()).append(" ShotokuCacheItem objects.<br />"); + sb.append("Objects in cache:<br />"); + for (Object key : cache.keySet()) { + sb.append(key.toString()).append(" : ").append( + cache.get(key).getClass().getName()).append("<br />"); + } + + sb.append("Cache items:<br />"); + for (ShotokuCacheItem sci : cacheItems) { + sb.append(sci.getClass().getName()).append("<br />"); + } + + return sb.toString(); } /* Modified: labs/shotoku/branches/qa/shotoku-base/src/java/org/jboss/shotoku/tools/Pair.java =================================================================== --- labs/shotoku/branches/qa/shotoku-base/src/java/org/jboss/shotoku/tools/Pair.java 2006-06-20 19:38:10 UTC (rev 4786) +++ labs/shotoku/branches/qa/shotoku-base/src/java/org/jboss/shotoku/tools/Pair.java 2006-06-20 19:41:11 UTC (rev 4787) @@ -56,4 +56,8 @@ public int hashCode() { return obj1.hashCode() + obj2.hashCode(); } + + public String toString() { + return "(" + obj1.toString() + ", " + obj2.toString() + ")"; + } } Modified: labs/shotoku/branches/qa/shotoku-base/src/java/org/jboss/shotoku/tools/Triple.java =================================================================== --- labs/shotoku/branches/qa/shotoku-base/src/java/org/jboss/shotoku/tools/Triple.java 2006-06-20 19:38:10 UTC (rev 4786) +++ labs/shotoku/branches/qa/shotoku-base/src/java/org/jboss/shotoku/tools/Triple.java 2006-06-20 19:41:11 UTC (rev 4787) @@ -43,4 +43,8 @@ public int hashCode() { return obj1.hashCode() + obj2.hashCode() + obj3.hashCode(); } + + public String toString() { + return "(" + obj1.toString() + ", " + obj2.toString()+ ", " + obj3.toString() + ")"; + } } Modified: labs/shotoku/branches/qa/shotoku-file-access/src/java/org/jboss/shotoku/fileaccess/FileAccessServlet.java =================================================================== --- labs/shotoku/branches/qa/shotoku-file-access/src/java/org/jboss/shotoku/fileaccess/FileAccessServlet.java 2006-06-20 19:38:10 UTC (rev 4786) +++ labs/shotoku/branches/qa/shotoku-file-access/src/java/org/jboss/shotoku/fileaccess/FileAccessServlet.java 2006-06-20 19:41:11 UTC (rev 4787) @@ -49,7 +49,7 @@ private void writeErrorMessage(HttpServletResponse response) throws IOException { response.setContentType("text/html"); - response.getWriter().println(FileAccessServlet.ACCESS_DENIED); + response.getOutputStream().println(FileAccessServlet.ACCESS_DENIED); } protected void doGet(HttpServletRequest request, HttpServletResponse response) @@ -105,8 +105,11 @@ try { Tools.transfer(ci.getIs(), os); } finally { - os.close(); - ci.getIs().close(); + try { + os.close(); + } finally { + ci.getIs().close(); + } } } catch (Exception e) { log.info("Unable to send a file.", e); Modified: labs/shotoku/branches/qa/shotoku-tags/src/java/org/jboss/shotoku/tags/AbstractTag.java =================================================================== --- labs/shotoku/branches/qa/shotoku-tags/src/java/org/jboss/shotoku/tags/AbstractTag.java 2006-06-20 19:38:10 UTC (rev 4786) +++ labs/shotoku/branches/qa/shotoku-tags/src/java/org/jboss/shotoku/tags/AbstractTag.java 2006-06-20 19:41:11 UTC (rev 4787) @@ -8,43 +8,64 @@ * @author Adam Warski (ad...@as...) */ public abstract class AbstractTag implements Tag { - private String name; - private String author; - private String resourceId; - private String data; + private String name; - private Date dateCreated; + private String author; - public AbstractTag(String name, String author, String resourceId, - String data, Date dateCreated) { - this.name = name; - this.author = author; - this.resourceId = resourceId; - this.data = data; - this.dateCreated = dateCreated; - } + private String resourceId; - /* - * TAG implementation. - */ + private String data; - public String getName() { - return name; - } + private Date dateCreated; - public String getAuthor() { - return author; - } + public AbstractTag(String name, String author, String resourceId, + String data, Date dateCreated) { + this.name = name; + this.author = author; + this.resourceId = resourceId; + this.data = data; + this.dateCreated = dateCreated; + } - public String getResourceId() { - return resourceId; - } + /* + * TAG implementation. + */ - public String getData() { - return data; - } + public String getName() { + return name; + } - public Date getDateCreated() { - return dateCreated; - } -} + public String getAuthor() { + return author; + } + + public String getResourceId() { + return resourceId; + } + + public String getData() { + return data; + } + + public Date getDateCreated() { + return dateCreated; + } + +public boolean equals(Object obj) { + if (obj == null) { + return false; + } + + if (obj.getClass().equals(this.getClass())) { + AbstractTag otherTag = (AbstractTag) obj; + + if (name.equals(otherTag.getName()) + && ((data == null && otherTag.getData() == null) || (data != null && data.equals(otherTag.getData()))) + && resourceId.equals(otherTag.getResourceId()) + && author.equals(otherTag.getAuthor())) { + return true; + } + } + + return false; + }} Modified: labs/shotoku/branches/qa/shotoku-tags/src/java/org/jboss/shotoku/tags/service/TagServiceImpl.java =================================================================== --- labs/shotoku/branches/qa/shotoku-tags/src/java/org/jboss/shotoku/tags/service/TagServiceImpl.java 2006-06-20 19:38:10 UTC (rev 4786) +++ labs/shotoku/branches/qa/shotoku-tags/src/java/org/jboss/shotoku/tags/service/TagServiceImpl.java 2006-06-20 19:41:11 UTC (rev 4787) @@ -22,9 +22,11 @@ package org.jboss.shotoku.tags.service; import java.util.Calendar; +import java.util.HashMap; import java.util.List; import java.util.ArrayList; import java.util.Iterator; +import java.util.Map; import java.net.URLEncoder; import java.io.UnsupportedEncodingException; @@ -54,246 +56,310 @@ * @author Adam Warski (ad...@as...) * @author Damon Sicore (da...@si...) */ -@Service(objectName=org.jboss.shotoku.tags.tools.Constants.TAG_SERVICE_NAME) +@Service(objectName = org.jboss.shotoku.tags.tools.Constants.TAG_SERVICE_NAME) @Local(TagServiceLocal.class) @Management(TagService.class) @Depends(Constants.SHOTOKU_SERVICE_NAME) -public class TagServiceImpl extends AdministratedServiceImpl - implements TagService, TagServiceLocal { - private static final Logger log = Logger.getLogger(TagService.class); +public class TagServiceImpl extends AdministratedServiceImpl implements + TagService, TagServiceLocal { + private static final Logger log = Logger.getLogger(TagService.class); - /* - * Service lifecycle management. - */ + /* + * Service lifecycle management. + */ - public void create() throws Exception { - super.create(); + public void create() throws Exception { + super.create(); - // Enabling administration for this service. - Tools.getService().addAdministratedService(new AdministratedServiceGetter() { - public AdministratedService getService() { - return TagTools.getService(); - } - }); + // Enabling administration for this service. + Tools.getService().addAdministratedService( + new AdministratedServiceGetter() { + public AdministratedService getService() { + return TagTools.getService(); + } + }); - setTimerInterval(10000); + setTimerInterval(10000); - log.info("Tag service created."); - } + log.info("Tag service created."); + } - public void start() throws Exception { - super.start(); + public void start() throws Exception { + super.start(); - // Starting the updater thread. - new Thread() { - { - setDaemon(true); - } + // Starting the updater thread. + new Thread() { + { + setDaemon(true); + } - public void run() { - while (getServiceRunnable()) { - try { - sleep(getTimerInterval()); - } catch (InterruptedException e) { - e.printStackTrace(); - } + public void run() { + while (getServiceRunnable()) { + try { + sleep(getTimerInterval()); + } catch (InterruptedException e) { + e.printStackTrace(); + } - try { - update(); - } catch (Throwable t) { - // Making sure that an exception won't stop the thread. - } + try { + update(); + } catch (Throwable t) { + // Making sure that an exception won't stop the thread. + } - setLastUpdate(Calendar.getInstance().getTimeInMillis()); - } + setLastUpdate(Calendar.getInstance().getTimeInMillis()); + } - log.info("Tag service deaemon thread terminated."); - } - }.start(); + log.info("Tag service deaemon thread terminated."); + } + }.start(); - log.info("Tag service started with update interval: "+ getTimerInterval()); - } + log.info("Tag service started with update interval: " + + getTimerInterval()); + } - public void stop() { - super.stop(); - log.info("Tag service signaled to stop."); - } + public void stop() { + super.stop(); + log.info("Tag service signaled to stop."); + } - public void destroy() { - } + public void destroy() { + } - /* - * Timer-handling functions. - */ + /* + * Timer-handling functions. + */ - public void update() { + public void update() { - } + } - public String getServiceId() { - return "ShotokuTagService"; - } + public String getServiceId() { + return "ShotokuTagService"; + } - public String getServiceName() { - return "Tag service"; - } + public String getServiceName() { + return "Tag service"; + } - public String getServiceDescription() { - return "Shotoku tag service"; - } + public String getServiceDescription() { + return "Shotoku tag service"; + } - /* - * TagService implementation. - */ + /* + * TagService implementation. + */ - @PersistenceContext - private EntityManager manager; + @PersistenceContext + private EntityManager manager; - private TagEntity getTagEntity(Tag t) { - TagEntity te = new TagEntity(); + /** + * MIN_SIMILARITY - minimal similarity for checking relatedTags needed + */ + private double MIN_SIMILARITY = 0.7d; - te.setAuthor(t.getAuthor()); - te.setData(t.getData()); - te.setDateCreated(t.getDateCreated()); - te.setName(t.getName()); - te.setResourceId(t.getResourceId()); - te.setType(t.getType()); + private TagEntity getTagEntity(Tag t) { + TagEntity te = new TagEntity(); - return te; - } + te.setAuthor(t.getAuthor()); + te.setData(t.getData()); + te.setDateCreated(t.getDateCreated()); + te.setName(t.getName()); + te.setResourceId(t.getResourceId()); + te.setType(t.getType()); - public void addTag(Tag t) throws TagAddException { - try { - manager.persist(getTagEntity(t)); - } catch (Throwable e) { - throw new TagAddException(e); - } - } + return te; + } - public void deleteTag(Tag t) throws TagDeleteException { - try { - manager.remove(getTagEntity(t)); - } catch (Throwable e) { - throw new TagDeleteException(e); - } - } + public void addTag(Tag t) throws TagAddException { + try { + manager.persist(getTagEntity(t)); + } catch (Throwable e) { + throw new TagAddException(e); + } + } - public List<Tag> getTags(String resourceId) throws TagGetException { - try { - //noinspection unchecked - List<TagEntity> result = manager.createQuery( - "from TagEntity where resourceId = :resourceId order by dateCreated desc"). - setParameter("resourceId", resourceId).getResultList(); + public void deleteTag(Tag t) throws TagDeleteException { + try { + manager.remove(getTagEntity(t)); + } catch (Throwable e) { + throw new TagDeleteException(e); + } + } - List<Tag> ret = new ArrayList<Tag>(); - for (TagEntity te : result) { - ret.add(te.getTag()); - } + public List<Tag> getTags(String resourceId) throws TagGetException { + try { + // noinspection unchecked + List<TagEntity> result = manager + .createQuery( + "from TagEntity where resourceId = :resourceId order by dateCreated desc") + .setParameter("resourceId", resourceId).getResultList(); - return ret; - } catch (Throwable e) { - throw new TagGetException(e); - } - } + List<Tag> ret = new ArrayList<Tag>(); + for (TagEntity te : result) { + ret.add(te.getTag()); + } - public Tag getTag(String tagName) throws TagGetException { - try { - //noinspection unchecked - TagEntity result = (TagEntity) manager.createQuery("from TagEntity where name = :name"). - setParameter("name", tagName).getSingleResult(); + return ret; + } catch (Throwable e) { + throw new TagGetException(e); + } + } - if (result == null) { - return null; - } + public Tag getTag(String tagName) throws TagGetException { + try { + // noinspection unchecked + TagEntity result = (TagEntity) manager.createQuery( + "from TagEntity where name = :name").setParameter("name", + tagName).getSingleResult(); - return result.getTag(); - } catch (Throwable e) { - throw new TagGetException(e); - } - } + if (result == null) { + return null; + } - public List<Tag> getTags(List<String> tagNames) throws TagGetException { - try { - StringBuffer querySb = new StringBuffer("from TagEntity where "); - int i = 0; - for (Iterator iter = tagNames.iterator(); iter.hasNext();) { - querySb.append("name").append(" = :name").append(i); + return result.getTag(); + } catch (Throwable e) { + throw new TagGetException(e); + } + } - iter.next(); + public List<Tag> getTags(List<String> tagNames) throws TagGetException { + try { + StringBuffer querySb = new StringBuffer("from TagEntity where "); + int i = 0; + for (Iterator iter = tagNames.iterator(); iter.hasNext();) { + querySb.append("name").append(" = :name").append(i); - if (iter.hasNext()) { - querySb.append(" and "); - } + iter.next(); - i++; - } + if (iter.hasNext()) { + querySb.append(" and "); + } - Query query = manager.createQuery(querySb.toString()); - i = 0; - for (String tagName : tagNames) { - query.setParameter("name" + i++, tagName); - } + i++; + } - //noinspection unchecked - List<TagEntity> result = query.getResultList(); + Query query = manager.createQuery(querySb.toString()); + i = 0; + for (String tagName : tagNames) { + query.setParameter("name" + i++, tagName); + } - List<Tag> ret = new ArrayList<Tag>(); - for (TagEntity te : result) { - ret.add(te.getTag()); - } + // noinspection unchecked + List<TagEntity> result = query.getResultList(); - return ret; - } catch (Throwable e) { - throw new TagGetException(e); - } - } + List<Tag> ret = new ArrayList<Tag>(); + for (TagEntity te : result) { + ret.add(te.getTag()); + } - public List<Tag> getRelatedTags(List<Tag> relateTo) throws TagGetException { - return null; - } + return ret; + } catch (Throwable e) { + throw new TagGetException(e); + } + } - public List<Tag> getTagsByAuthor(String author) throws TagGetException { - try { - //noinspection unchecked - List<TagEntity> result = manager.createQuery( - "from TagEntity where author = :author order by dateCreated desc"). - setParameter("author", author).getResultList(); + public List<Tag> getRelatedTags(List<Tag> relateTo) throws TagGetException { + List<Tag> ret = new ArrayList<Tag>(); - List<Tag> ret = new ArrayList<Tag>(); - for (TagEntity te : result) { - ret.add(te.getTag()); - } + Map<String, List<Tag>> otherResources = new HashMap<String, List<Tag>>(); - return ret; - } catch (Throwable e) { - throw new TagGetException(e); - } - } + for (Tag relatedTag : relateTo) { + List<TagEntity> result = manager.createQuery( + "from TagEntity where name = :name").setParameter("name", + relatedTag.getName()).getResultList(); - public String getFeedLink(FeedType feedType, String data, String type) { - try { - return "/feeds/tag/" + feedType.toString() + "/" + - URLEncoder.encode(data, "UTF-8") + "/" + type; - } catch (UnsupportedEncodingException e) { - return ""; - } - } + for (TagEntity otherTag : result) { + if (!otherResources.containsKey(otherTag.getResourceId())) { + otherResources.put(otherTag.getResourceId(), + getTags(otherTag.getResourceId())); + } + } + } - public String getFeedLink(FeedType feedType, List<String> dataList, String type) { - StringBuffer sb = new StringBuffer(); + for (List<Tag> tagList : otherResources.values()) { + if (checkSimilarity(relateTo, tagList) >= MIN_SIMILARITY) { + ret.addAll(tagList); + } + } - for (Iterator<String> iter = dataList.iterator(); iter.hasNext();) { - sb.append(iter.next()); - if (iter.hasNext()) { - sb.append("+"); - } - } + // don't return "relateTo" members + List<Tag> endRet = new ArrayList<Tag>(ret); + for (Tag tag : ret) { + if (tagListContainsTag(tag, relateTo)) { + endRet.remove(tag); + } + } + + return endRet; + } + + private boolean tagListContainsTag(Tag tag, List<Tag> listToCheck) { + for (Tag tag2 : listToCheck) { + if (tag.getName().equals(tag2.getName())) { + return true; + } + } + + return false; + } - try { - return "/feeds/tag/" + feedType.toString() + "/" + - URLEncoder.encode(sb.toString(), "UTF-8") + "/" + type; - } catch (UnsupportedEncodingException e) { - return ""; - } - } + private double checkSimilarity(List<Tag> givenTags, List<Tag> listToCheck) { + double ret = 0; + + for (Tag tag : givenTags) { + if (tagListContainsTag(tag,listToCheck)) { + ret++; + } + } + + return ret / (double) givenTags.size(); + } + + public List<Tag> getTagsByAuthor(String author) throws TagGetException { + try { + // noinspection unchecked + List<TagEntity> result = manager + .createQuery( + "from TagEntity where author = :author order by dateCreated desc") + .setParameter("author", author).getResultList(); + + List<Tag> ret = new ArrayList<Tag>(); + for (TagEntity te : result) { + ret.add(te.getTag()); + } + + return ret; + } catch (Throwable e) { + throw new TagGetException(e); + } + } + + public String getFeedLink(FeedType feedType, String data, String type) { + try { + return "/feeds/tag/" + feedType.toString() + "/" + + URLEncoder.encode(data, "UTF-8") + "/" + type; + } catch (UnsupportedEncodingException e) { + return ""; + } + } + + public String getFeedLink(FeedType feedType, List<String> dataList, + String type) { + StringBuffer sb = new StringBuffer(); + + for (Iterator<String> iter = dataList.iterator(); iter.hasNext();) { + sb.append(iter.next()); + if (iter.hasNext()) { + sb.append("+"); + } + } + + try { + return "/feeds/tag/" + feedType.toString() + "/" + + URLEncoder.encode(sb.toString(), "UTF-8") + "/" + type; + } catch (UnsupportedEncodingException e) { + return ""; + } + } } |
Author: dam...@jb... Date: 2006-06-20 15:38:10 -0400 (Tue, 20 Jun 2006) New Revision: 4786 Added: labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/configuration/to-copy/mail-service.xml labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/exceptions/ScoresException.java labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-tagme/src/java/org/jboss/labs/tagme/gwt/client/LabsDialogBox.java labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/management/EMailNotifier.java labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/jbosswiki/wiki-management/src/java/org/jboss/wiki/EMailNotifierSLSB.java Removed: labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/protocol/GetScoresRequestImpl.java labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/protocol/GetScoresResponseImpl.java labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/protocol/GetScoresRequest.java labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/protocol/GetScoresResponse.java labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/RecordManager.java labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/ScoresManagerSync.java Modified: labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDB.java labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/StatusDescriptor.java labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/common/Constants.java labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/exceptions/GetScoresException.java labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/exceptions/ScoresSaveException.java labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/Last7DaysStatusPlugin.java labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/codelines/CodeLinesEvaluator.java labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/codelines/CodeLinesPlugin.java labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/ScoresMDB.java labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/ScoresManager.java labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-tagme/src/java/org/jboss/labs/tagme/gwt/client/TagMe.java labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-tagme/src/java/org/jboss/labs/tagme/gwt/client/TagMeShowPopupListener.java labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-theme/jbossForgeLayout.war/layouts/jbossForge.jsp labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/WikiCommon.java labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/jbosswiki/wiki-management/src/java/org/jboss/wiki/MailNotificationBean.java Log: MERGED: -r 4761:4785 https://svn.labs.jboss.com/labs/jbosslabs/trunk into qa for Labs 1.1-SP1 lol. Copied: labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/configuration/to-copy/mail-service.xml (from rev 4785, labs/jbosslabs/trunk/portal-extensions/configuration/to-copy/mail-service.xml) Modified: labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDB.java =================================================================== --- labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDB.java 2006-06-20 19:28:56 UTC (rev 4785) +++ labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDB.java 2006-06-20 19:38:10 UTC (rev 4786) @@ -123,32 +123,36 @@ downloadCounters.get(link).increment(); try { - //CountersServiceInterface countersService = - // (CountersServiceInterface) ctx.lookup(CountersServiceInterface.jndiName); - //countersService.incrementCounter(link); + CountersServiceInterface countersService = + (CountersServiceInterface) ctx.lookup(CountersServiceInterface.jndiName); + countersService.incrementCounter(link); + // MDB CODE COMMENTED OUT BECAUSE OF MDB ISSUES // 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"); - QueueConnectionFactory factory = - (QueueConnectionFactory) ctx.lookup("java:/ConnectionFactory"); - sess =factory.createQueueConnection().createQueueSession(false, - QueueSession.AUTO_ACKNOWLEDGE); - if (sess != null) - { - TextMessage msg = sess.createTextMessage(link); - sess.createSender(queue).send(msg); - } + //QueueSession sess = null; + //Queue queue = null; + //queue = (Queue) ctx.lookup("queue/jblab_counters"); + //QueueConnectionFactory factory = + // (QueueConnectionFactory) ctx.lookup("java:/ConnectionFactory"); + //sess =factory.createQueueConnection().createQueueSession(false, + // QueueSession.AUTO_ACKNOWLEDGE); + //if (sess != null) + //{ + // TextMessage msg = sess.createTextMessage(link); + // sess.createSender(queue).send(msg); + //} } catch (NamingException e) { getLogger().error("CountersService was not found while incrementing counter.",e); } - catch (JMSException e) - { - getLogger().error("Problem while using JMS to send increment command to MDB.",e); + //catch (JMSException e) + //{ + // getLogger().error("Problem while using JMS to send increment command to MDB.",e); + //} + catch (Exception e) { + getLogger().error("CountersService problem while incrementing counter.",e); } } } Modified: labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java =================================================================== --- labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java 2006-06-20 19:28:56 UTC (rev 4785) +++ labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java 2006-06-20 19:38:10 UTC (rev 4786) @@ -22,7 +22,6 @@ package org.jboss.forge.status; -import java.sql.Timestamp; import java.util.ArrayList; import java.util.Calendar; import java.util.HashMap; @@ -49,7 +48,6 @@ import org.jboss.forge.status.templates.Column; import org.jboss.forge.status.templates.Columns; import org.jboss.forge.status.templates.MatrixTemplate; -import org.jboss.forge.status.tools.ScoresManagerSync; import org.jboss.forge.status.tools.ScoresManager; import org.jboss.logging.Logger; @@ -75,7 +73,7 @@ private List<PluginConf> pluginsConf; - private Timestamp timestamp; + private Calendar updateDate; private Logger log; @@ -85,7 +83,8 @@ * @param pluginsRoot Node defining Plugins used in the Matrix */ public Status(String portalName, Node statusRoot, Node pluginsRoot, - org.jboss.shotoku.Node serviceNode) { + org.jboss.shotoku.Node serviceNode) + throws GetScoresException { log = Logger.getLogger(this.getClass()); @@ -94,23 +93,25 @@ pluginsConf = getPluginsConfList(pluginsRoot); ServiceConf serviceConf = new ServiceConfImpl(serviceNode); - ScoresManagerSync.init(portalName, serviceConf); + ScoresManager.init(portalName, serviceConf); PluginsValues pluginsValues; - try { - // Get latest available scores - ScoresManager.init(portalName, serviceConf); - pluginsValues = ScoresManager.getLatestScores(); - - // Compute and save current scores + + // Compute and save current scores + try { ScoresManager.save(projects, pluginsConf); - timestamp = ScoresManager.requestCurrentScores(); } catch (ScoresSaveException e) { log.error("Saving scores failed ", e); - return; + } + + // Get latest available scores + try { + ScoresManager.init(portalName, serviceConf); + pluginsValues = ScoresManager.getLatestScores(); + updateDate = pluginsValues.getDate(); } catch (GetScoresException e) { log.error("Getting computed scores failed ", e); - return; + throw e; } // Get columns to display on the main page @@ -217,54 +218,52 @@ log.info("Checking for updated scores."); - PluginsValues pluginsValues; + PluginsValues pluginsValues = null; + // Check for updated scores try { - pluginsValues = ScoresManager.getScores(timestamp); + pluginsValues = ScoresManager.getLatestScores(); } catch (GetScoresException e) { - log.warn("Resending \"get\" request failed."); - return false; + log.warn("Failed to get lates scores."); } - if (pluginsValues == null) { - - Calendar tsCal = Calendar.getInstance(); - tsCal.setTime(timestamp); - Calendar now = Calendar.getInstance(); - - if (tsCal.get(Calendar.DAY_OF_MONTH) != - now.get(Calendar.DAY_OF_MONTH)) { - - try { - ScoresManager.save(projects, pluginsConf); - //TODO *Maybe* get rid of "save", have only "get" - // and service performing "save" on it's own - // (after necessary init or using it own conf)? - timestamp = ScoresManager.requestCurrentScores(); - } catch (ScoresSaveException e) { - log.warn("Sending \"save\" request failed."); - } catch (GetScoresException e) { - log.warn("Sending \"get\" request failed."); - } + // Perform save if needed + if ((pluginsValues == null) || needsSave(pluginsValues.getDate())){ + + try { + ScoresManager.save(projects, pluginsConf); + } catch (ScoresSaveException e) { + log.warn("Sending \"save\" request failed."); } - - return false; } + // Refresh if scores are new + if ((pluginsValues != null) && + (pluginsValues.getDate() != updateDate)) { + + refreshScores(pluginsValues); + } + + return true; + } + + private boolean needsSave(Calendar date) { + + Calendar now = Calendar.getInstance(); + + return (now.get(Calendar.DAY_OF_MONTH) != date.get(Calendar.DAY_OF_MONTH)); + } + + private void refreshScores(PluginsValues pluginsValues) { + log.info("Refreshing scores..."); mainPageColumns.update(pluginsValues); matrixTemplate.update(pluginsValues); - log.info("Finished refreshing scores."); + updateDate = pluginsValues.getDate(); - try { - timestamp = ScoresManager.requestCurrentScores(); - } catch (GetScoresException e) { - log.warn("Sending \"get\" request failed."); - } - - return true; + log.info("Finished refreshing scores."); } } \ No newline at end of file Modified: labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/StatusDescriptor.java =================================================================== --- labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/StatusDescriptor.java 2006-06-20 19:28:56 UTC (rev 4785) +++ labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/StatusDescriptor.java 2006-06-20 19:38:10 UTC (rev 4786) @@ -22,10 +22,12 @@ package org.jboss.forge.status; +import java.util.HashMap; import java.util.Map; import java.io.IOException; import org.jboss.forge.status.common.Locations; +import org.jboss.forge.status.exceptions.GetScoresException; import org.jboss.portal.common.context.DelegateContext; import org.jboss.shotoku.ContentManager; @@ -44,14 +46,28 @@ */ public class StatusDescriptor { - private DelegateContext context; - private Map<String,DelegateContext> projectContexts; - private Map<String,DelegateContext> columnContexts; + private DelegateContext context = new DelegateContext(); + private Map<String,DelegateContext> projectContexts + = new HashMap<String,DelegateContext>(); + private Map<String,DelegateContext> columnContexts + = new HashMap<String,DelegateContext>(); + + private String portalName; + private ContentManager cm; + private Status status; public StatusDescriptor(String portalName, ContentManager cm) { + this.portalName = portalName; + this.cm = cm; + + init(); + } + + private void init() { + try { String statusPath = Locations.getXmlCmPath(portalName); Node statusRoot = getRoot(cm , statusPath); @@ -67,19 +83,22 @@ fillContext(); + } catch (GetScoresException e){ + // do nothing } catch (Exception e) { e.printStackTrace(); } } private void fillContext() { - - context = new DelegateContext(); - status.fillContext(context); - projectContexts = status.getProjectContexts(); - columnContexts = status.getColumnContexts(); - + if (status != null) { + + status.fillContext(context); + + projectContexts = status.getProjectContexts(); + columnContexts = status.getColumnContexts(); + } } public DelegateContext getContext() { @@ -107,7 +126,11 @@ public void update() { - if (status.needsUpdate()) { + if (status == null) { + init(); + } + + if ((status != null) && (status.needsUpdate())) { fillContext(); } } Modified: labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/common/Constants.java =================================================================== --- labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/common/Constants.java 2006-06-20 19:28:56 UTC (rev 4785) +++ labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/common/Constants.java 2006-06-20 19:38:10 UTC (rev 4786) @@ -11,14 +11,12 @@ public static final String NAME_PROPERTY = "name"; public static final String SAVE_MESSAGE = "save"; - public static final String GET_SCORES_MESSAGE = "get"; public static final String STATUS_LOCAL_SERVICE = "Status/LocalScoresService"; public static final String STATUS_REMOTE_SERVICE = "Status/RemoteScoresService"; public static final long CACHE_INTERVAL = 5*60*1000; /* milliseconds */ - //TODO conf via cms? - + /** * This class cannot be instatiated. */ Modified: labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/exceptions/GetScoresException.java =================================================================== --- labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/exceptions/GetScoresException.java 2006-06-20 19:28:56 UTC (rev 4785) +++ labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/exceptions/GetScoresException.java 2006-06-20 19:38:10 UTC (rev 4786) @@ -27,7 +27,7 @@ * Indicates that searching for saved scores failed. */ -public class GetScoresException extends Exception { +public class GetScoresException extends ScoresException { private static final long serialVersionUID = 7291136165537810321L; @@ -38,5 +38,9 @@ public GetScoresException(Exception e) { super(e); } + + public GetScoresException(String msg) { + super(msg); + } } Copied: labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/exceptions/ScoresException.java (from rev 4785, labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/exceptions/ScoresException.java) Modified: labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/exceptions/ScoresSaveException.java =================================================================== --- labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/exceptions/ScoresSaveException.java 2006-06-20 19:28:56 UTC (rev 4785) +++ labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/exceptions/ScoresSaveException.java 2006-06-20 19:38:10 UTC (rev 4786) @@ -27,7 +27,7 @@ * Indicates that computing or saving scores failed. */ -public class ScoresSaveException extends Exception { +public class ScoresSaveException extends ScoresException { private static final long serialVersionUID = 7291136165537810321L; Modified: labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/Last7DaysStatusPlugin.java =================================================================== --- labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/Last7DaysStatusPlugin.java 2006-06-20 19:28:56 UTC (rev 4785) +++ labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/Last7DaysStatusPlugin.java 2006-06-20 19:38:10 UTC (rev 4786) @@ -29,7 +29,7 @@ import org.jboss.forge.status.exceptions.InvalidPluginPropertiesException; import org.jboss.forge.status.exceptions.GetScoresException; import org.jboss.forge.status.tools.Plugins; -import org.jboss.forge.status.tools.ScoresManagerSync; +import org.jboss.forge.status.tools.ScoresManager; /** * @author Pawel Wrzeszcz (paw...@gm...) @@ -79,7 +79,7 @@ try { - prevValue = ScoresManagerSync.getValue( + prevValue = ScoresManager.getValue( insidePlugin.getId(), projectId, cal, now); } catch (GetScoresException e) { return 0; Modified: labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/codelines/CodeLinesEvaluator.java =================================================================== --- labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/codelines/CodeLinesEvaluator.java 2006-06-20 19:28:56 UTC (rev 4785) +++ labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/codelines/CodeLinesEvaluator.java 2006-06-20 19:38:10 UTC (rev 4786) @@ -128,7 +128,7 @@ repository.setAuthenticationManager(authManager); /* Analyze */ - log.debug("Analyzing repository " + repository.getLocation() + "."); + log.info("Analyzing repository " + repository.getLocation() + "."); return repository; } Modified: labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/codelines/CodeLinesPlugin.java =================================================================== --- labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/codelines/CodeLinesPlugin.java 2006-06-20 19:28:56 UTC (rev 4785) +++ labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/codelines/CodeLinesPlugin.java 2006-06-20 19:38:10 UTC (rev 4786) @@ -57,11 +57,6 @@ @Override public long getValue(String projectId) { - System.out.print("clp getValue: "); - System.out.print(projectId + " "); - System.out.println(cachedValues); - //TODO and now NPE appears, where exactly?? - if (!cachedValues.containsKey(projectId)) { long cl = 0; @@ -79,6 +74,8 @@ } } - return cachedValues.get(projectId).longValue(); + Long value = cachedValues.get(projectId); + + return value == null ? 0 : value.longValue(); } } Modified: labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/ScoresMDB.java =================================================================== --- labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/ScoresMDB.java 2006-06-20 19:28:56 UTC (rev 4785) +++ labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/ScoresMDB.java 2006-06-20 19:38:10 UTC (rev 4786) @@ -22,8 +22,6 @@ package org.jboss.forge.status.service.impl; -import java.sql.Timestamp; -import java.util.Calendar; import java.util.List; import javax.ejb.ActivationConfigProperty; @@ -36,17 +34,11 @@ import org.jboss.forge.common.projects.Projects; import org.jboss.forge.status.common.Constants; -import org.jboss.forge.status.exceptions.GetScoresException; import org.jboss.forge.status.exceptions.ScoresSaveException; -import org.jboss.forge.status.service.impl.protocol.GetScoresResponseImpl; -import org.jboss.forge.status.service.protocol.GetScoresRequest; -import org.jboss.forge.status.service.protocol.GetScoresResponse; import org.jboss.forge.status.service.protocol.PluginConf; -import org.jboss.forge.status.service.protocol.PluginsValues; import org.jboss.forge.status.service.protocol.SaveRequest; -import org.jboss.forge.status.tools.RecordManager; -import org.jboss.forge.status.tools.ScoresManagerSync; +import org.jboss.forge.status.tools.ScoresManager; import org.jboss.logging.Logger; @@ -79,14 +71,9 @@ SaveRequest saveRequest = (SaveRequest) message.getObject(); handleRequest(saveRequest); + } else { + log.info("Unknown request: " + requestName); } - - if (requestName.equals(Constants.GET_SCORES_MESSAGE)) { - - GetScoresRequest getScoresRequest = - (GetScoresRequest) message.getObject(); - handleRequest(getScoresRequest); - } log.info("Finished processing request: " + requestName); @@ -101,29 +88,10 @@ List<PluginConf> pluginsConf = saveRequest.getPluginsConf(); try { - ScoresManagerSync.save(projects, pluginsConf); + ScoresManager.saveSync(projects, pluginsConf); } catch (ScoresSaveException e) { log.warn("Error processing save request.", e); } } - - private static void handleRequest(GetScoresRequest request) { - - Calendar cal = request.getCalendar(); - Timestamp timestamp = request.getTimestamp(); - - PluginsValues pluginsValues = null; - try { - pluginsValues = ScoresManagerSync.getScores(cal); - } catch (GetScoresException e) { - log.warn("Error processing get request, returning null values."); - // If something is wrong, response will contain null pluginsValues - } - - GetScoresResponse response = - new GetScoresResponseImpl(pluginsValues, request); - - RecordManager.add(timestamp, response); - } } Deleted: labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/protocol/GetScoresRequestImpl.java =================================================================== --- labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/protocol/GetScoresRequestImpl.java 2006-06-20 19:28:56 UTC (rev 4785) +++ labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/protocol/GetScoresRequestImpl.java 2006-06-20 19:38:10 UTC (rev 4786) @@ -1,56 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2005, JBoss Inc., and individual contributors as indicated - * by the @authors tag. See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ - -package org.jboss.forge.status.service.impl.protocol; - -import java.sql.Timestamp; -import java.util.Calendar; -import org.jboss.forge.status.service.protocol.GetScoresRequest; - -/** -* @author Pawel Wrzeszcz -*/ -public class GetScoresRequestImpl implements GetScoresRequest { - - private static final long serialVersionUID = 7844595317056960170L; - - private Calendar cal; - private Timestamp timestamp; - - public GetScoresRequestImpl(Calendar cal, - Timestamp timestamp) { - - this.cal = cal; - this.timestamp = timestamp; - } - - public Calendar getCalendar() { - return cal; - } - - public Timestamp getTimestamp() { - return timestamp; - } - - - -} \ No newline at end of file Deleted: labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/protocol/GetScoresResponseImpl.java =================================================================== --- labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/protocol/GetScoresResponseImpl.java 2006-06-20 19:28:56 UTC (rev 4785) +++ labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/protocol/GetScoresResponseImpl.java 2006-06-20 19:38:10 UTC (rev 4786) @@ -1,54 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2005, JBoss Inc., and individual contributors as indicated - * by the @authors tag. See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ - -package org.jboss.forge.status.service.impl.protocol; - -import org.jboss.forge.status.service.protocol.GetScoresRequest; -import org.jboss.forge.status.service.protocol.GetScoresResponse; -import org.jboss.forge.status.service.protocol.PluginsValues; - -/** -* @author Pawel Wrzeszcz -*/ -public class GetScoresResponseImpl implements GetScoresResponse { - - private static final long serialVersionUID = 7844595317056960170L; - - private PluginsValues pluginsValues; - private GetScoresRequest request; - - public GetScoresResponseImpl(PluginsValues pluginsValues, - GetScoresRequest request) { - - this.pluginsValues = pluginsValues; - this.request = request; - } - - public PluginsValues getPluginsValues() { - return pluginsValues; - } - - public GetScoresRequest getRequest() { - return request; - } - -} \ No newline at end of file Deleted: labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/protocol/GetScoresRequest.java =================================================================== --- labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/protocol/GetScoresRequest.java 2006-06-20 19:28:56 UTC (rev 4785) +++ labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/protocol/GetScoresRequest.java 2006-06-20 19:38:10 UTC (rev 4786) @@ -1,38 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2005, JBoss Inc., and individual contributors as indicated - * by the @authors tag. See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ - -package org.jboss.forge.status.service.protocol; - -import java.io.Serializable; -import java.sql.Timestamp; -import java.util.Calendar; - -/** -* @author Pawel Wrzeszcz -*/ -public interface GetScoresRequest extends Serializable { - - public Calendar getCalendar(); - - public Timestamp getTimestamp(); - -} \ No newline at end of file Deleted: labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/protocol/GetScoresResponse.java =================================================================== --- labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/protocol/GetScoresResponse.java 2006-06-20 19:28:56 UTC (rev 4785) +++ labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/protocol/GetScoresResponse.java 2006-06-20 19:38:10 UTC (rev 4786) @@ -1,36 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2005, JBoss Inc., and individual contributors as indicated - * by the @authors tag. See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ - -package org.jboss.forge.status.service.protocol; - -import java.io.Serializable; - -/** -* @author Pawel Wrzeszcz -*/ -public interface GetScoresResponse extends Serializable { - - public PluginsValues getPluginsValues(); - - public GetScoresRequest getRequest(); - -} \ No newline at end of file Deleted: labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/RecordManager.java =================================================================== --- labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/RecordManager.java 2006-06-20 19:28:56 UTC (rev 4785) +++ labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/RecordManager.java 2006-06-20 19:38:10 UTC (rev 4786) @@ -1,44 +0,0 @@ -package org.jboss.forge.status.tools; - -import java.sql.Timestamp; -import java.util.ArrayList; - -import org.jboss.forge.status.service.protocol.GetScoresResponse; - -/** - * @author Pawel Wrzeszcz - */ -public class RecordManager { - - private static ArrayList<GetScoresResponse> buff = - new ArrayList<GetScoresResponse> (); - - private static int maxSize = 100; - - public static void add (Timestamp sent, GetScoresResponse response) { - - // Remove the earliest item if the cache is full - if (buff.size () > maxSize) { - buff.remove (0); - } - - buff.add(response); - } - - public static GetScoresResponse get(Timestamp sent) { - - for (int i = 0; i < buff.size (); i++) { - - GetScoresResponse resp = buff.get(i); - Timestamp ts = resp.getRequest().getTimestamp(); - - if (ts.equals(sent)) { - - buff.remove(i); - return resp; - } - } - return null; - } - -} Modified: labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/ScoresManager.java =================================================================== --- labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/ScoresManager.java 2006-06-20 19:28:56 UTC (rev 4785) +++ labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/ScoresManager.java 2006-06-20 19:38:10 UTC (rev 4786) @@ -23,7 +23,6 @@ package org.jboss.forge.status.tools; import java.io.Serializable; -import java.sql.Timestamp; import java.util.Calendar; import java.util.List; import java.util.Properties; @@ -38,14 +37,15 @@ import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; +import javax.rmi.PortableRemoteObject; 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.impl.protocol.GetScoresRequestImpl; +import org.jboss.forge.status.service.ScoresService; +import org.jboss.forge.status.service.ScoresServiceLocal; +import org.jboss.forge.status.service.ScoresServiceRemote; import org.jboss.forge.status.service.impl.protocol.SaveRequestImpl; -import org.jboss.forge.status.service.protocol.GetScoresRequest; -import org.jboss.forge.status.service.protocol.GetScoresResponse; import org.jboss.forge.status.service.protocol.PluginConf; import org.jboss.forge.status.service.protocol.PluginsValues; import org.jboss.forge.status.service.protocol.SaveRequest; @@ -58,15 +58,16 @@ public class ScoresManager { + private static String portalName; private static Properties properties; - private static boolean remote; + private static boolean isRemote; public static void init(String portalName, ServiceConf serviceConf) { - ScoresManagerSync.init(portalName, serviceConf); + ScoresManager.portalName = portalName; properties = serviceConf.getProperties(); - remote = serviceConf.isRemote(); + isRemote = serviceConf.isRemote(); } public static void save(Projects projects, List<PluginConf> pluginsConf) @@ -81,58 +82,54 @@ throw new ScoresSaveException(e); } } + + public static void saveSync(Projects projects, + List<PluginConf> pluginsConf) + throws ScoresSaveException { - public static Timestamp requestScores(Calendar cal) - throws GetScoresException { - - Timestamp timestamp = new Timestamp(System.currentTimeMillis()); - - GetScoresRequest getScoresRequest = - new GetScoresRequestImpl(cal, timestamp); + ScoresService service = null; try { - sendMessage(Constants.GET_SCORES_MESSAGE, getScoresRequest); - } catch (Exception e) { - throw new GetScoresException(e); + service = getService(); + } catch (NamingException e) { + throw new ScoresSaveException(e); } - - return timestamp; - } - public static Timestamp requestCurrentScores() - throws GetScoresException { + service.save(projects, pluginsConf, portalName); +} + public static boolean hasScores(Calendar cal) { - Calendar cal = Calendar.getInstance(); + ScoresService service; + try { + service = getService(); + } catch (NamingException e) { + return false; + } - return requestScores(cal); + return service.hasPluginsValues(portalName, cal); } - public static PluginsValues getScores(Timestamp timestamp) + + public static PluginsValues getScores(Calendar cal) throws GetScoresException { - - - GetScoresResponse response = RecordManager.get(timestamp); - - System.out.println("attempt"); - - if (response == null) { - return null; + + PluginsValues pluginsValues = null; + + try { + ScoresService service = getService(); + pluginsValues = service.getPluginsValues(portalName, cal); + } catch (Exception e) { + throw new GetScoresException(e); } - - PluginsValues pluginsValues = response.getPluginsValues(); - + if (pluginsValues == null) { - try { - sendMessage(Constants.GET_SCORES_MESSAGE, - response.getRequest()); - } catch (Exception e) { - throw new GetScoresException(e); - } + throw new GetScoresException(); } - + return pluginsValues; } + public static PluginsValues getLatestScores() throws GetScoresException { @@ -143,48 +140,115 @@ System.out.println("Trying " + cal.getTime().toString()); - if (ScoresManagerSync.hasScores(cal)) { - return ScoresManagerSync.getScores(cal); + if (ScoresManager.hasScores(cal)) { + return ScoresManager.getScores(cal); } - if ((attempts++) == Constants.MAX_ATTEMPTS) { - return null; + if ((++attempts) == Constants.MAX_ATTEMPTS) { + throw new GetScoresException( + "Can not find any recently saved scores. " + + "Gave up after " + attempts + " attempts."); } cal.add(Calendar.DAY_OF_MONTH, -1); } } + + /** + * For the specified plugin returns historical project score + * from the given <code>date</code> in the past. + * + * 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, + Calendar cal) + throws GetScoresException { + + PluginsValues pluginsValues = getScores(cal); + + return pluginsValues.getPluginValue(pluginId, projectId); + } + + public static long getValue(String id, String projectId, + Calendar start, Calendar end) throws GetScoresException { + + long value; + Calendar cal = start; + + for (;;) { + + if (cal.after(end)) { + throw new GetScoresException(); + } + + try { + value = getValue(id, projectId, cal); + return value; + } catch (GetScoresException e) { + // try next + cal.add(Calendar.DAY_OF_MONTH, 1); + } + } + } + private static ScoresService getService() throws NamingException { + + Context context = null; + if (isRemote) { + context = new InitialContext(properties); + } else { + context = new InitialContext(); + } + + // Perform look up using JNDI name of ejb object + String serviceBinding = + (isRemote ? Constants.STATUS_REMOTE_SERVICE : + Constants.STATUS_LOCAL_SERVICE); + Object ref = context.lookup(serviceBinding); + + // Narrow the reference of the object returned by lookup() method + ScoresService service = + (ScoresService) PortableRemoteObject.narrow( ref, + (isRemote ? ScoresServiceRemote.class : + ScoresServiceLocal.class)); + + return service; + } + private static void sendMessage(String name, Serializable request) throws - NamingException, JMSException { - + NamingException, JMSException { + Queue queue = null; QueueConnection connection = null; QueueSession session = null; QueueSender sender = null; - + Context context = null; - if (remote) { + if (isRemote) { context = new InitialContext(properties); } else { context = new InitialContext(); } - - queue = (Queue) context.lookup(Constants.QUEUE_NAME); - QueueConnectionFactory factory = - (QueueConnectionFactory) context.lookup("java:/ConnectionFactory"); - connection = factory.createQueueConnection(); - session = connection.createQueueSession(false, - QueueSession.AUTO_ACKNOWLEDGE); - - // Create message + + queue = (Queue) context.lookup(Constants.QUEUE_NAME); + QueueConnectionFactory factory = + (QueueConnectionFactory) context.lookup("java:/ConnectionFactory"); + connection = factory.createQueueConnection(); + session = connection.createQueueSession(false, + QueueSession.AUTO_ACKNOWLEDGE); + + // Create a message ObjectMessage message = session.createObjectMessage(); - message.setStringProperty("name", name); - message.setObject(request); - + message.setStringProperty("name", name); + message.setObject(request); + sender = session.createSender(queue); - sender.send(message); - session.close (); + sender.send(message); + session.close (); } + } Deleted: labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/ScoresManagerSync.java =================================================================== --- labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/ScoresManagerSync.java 2006-06-20 19:28:56 UTC (rev 4785) +++ labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/ScoresManagerSync.java 2006-06-20 19:38:10 UTC (rev 4786) @@ -1,182 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2005, JBoss Inc., and individual contributors as indicated - * by the @authors tag. See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ - -package org.jboss.forge.status.tools; - -import java.util.Calendar; -import java.util.List; -import java.util.Properties; - -import javax.naming.Context; -import javax.naming.InitialContext; -import javax.naming.NamingException; -import javax.rmi.PortableRemoteObject; - -import org.jboss.forge.common.projects.Projects; -import org.jboss.forge.status.common.Constants; -import org.jboss.forge.status.exceptions.GetScoresException; -import org.jboss.forge.status.exceptions.ScoresSaveException; -import org.jboss.forge.status.service.ScoresService; -import org.jboss.forge.status.service.ScoresServiceLocal; -import org.jboss.forge.status.service.ScoresServiceRemote; -import org.jboss.forge.status.service.protocol.PluginConf; -import org.jboss.forge.status.service.protocol.PluginsValues; -import org.jboss.forge.status.service.protocol.ServiceConf; - -/** -* @author Pawel Wrzeszcz (pawel.wrzeszcz [at] gmail.com) -*/ - -public class ScoresManagerSync { - - private static String portalName; - private static boolean isRemote; - private static Properties properties; - - public static void init(String portalName, ServiceConf serviceConf) { - - ScoresManagerSync.portalName = portalName; - - isRemote = serviceConf.isRemote(); - - properties = serviceConf.getProperties(); - } - - public static void save(Projects projects, List<PluginConf> pluginsConf) - throws ScoresSaveException { - - ScoresService service = null; - - try { - service = getService(); - } catch (NamingException e) { - throw new ScoresSaveException(e); - } - - service.save(projects, pluginsConf, portalName); - } - - public static PluginsValues getScores(Calendar cal) - throws GetScoresException { - - PluginsValues pluginsValues = null; - - try { - ScoresService service = getService(); - pluginsValues = service.getPluginsValues(portalName, cal); - } catch (Exception e) { - throw new GetScoresException(e); - } - - if (pluginsValues == null) { - throw new GetScoresException(); - } - - return pluginsValues; - } - - public static boolean hasScores(Calendar cal) { - - ScoresService service; - try { - service = getService(); - } catch (NamingException e) { - return false; - } - - return service.hasPluginsValues(portalName, cal); - } - - /** - * For the specified plugin returns historical project score - * from the given <code>date</code> in the past. - * - * 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, - Calendar cal) - throws GetScoresException { - - PluginsValues pluginsValues = getScores(cal); - - return pluginsValues.getPluginValue(pluginId, projectId); - } - - public static PluginsValues getCurrentScores() - throws GetScoresException { - - Calendar now = Calendar.getInstance(); - - return getScores(now); - } - - private static ScoresService getService() throws NamingException { - - Context context = new InitialContext(properties); - - // Perform look up using JNDI name of ejb object - String serviceBinding = - (isRemote ? Constants.STATUS_REMOTE_SERVICE : - Constants.STATUS_LOCAL_SERVICE); - Object ref = context.lookup(serviceBinding); - - // Narrow the reference of the object returned by lookup() method - ScoresService service = - (ScoresService) PortableRemoteObject.narrow( ref, - (isRemote ? ScoresServiceRemote.class : - ScoresServiceLocal.class)); - - return service; - } - - public static long getValue(String id, String projectId, - Calendar start, Calendar end) throws GetScoresException { - - long value; - Calendar cal = start; - - for (;;) { - - if (cal.after(end)) { - throw new GetScoresException(); - } - - try { - value = getValue(id, projectId, cal); - return value; - } catch (GetScoresException e) { - // try next - cal.add(Calendar.DAY_OF_MONTH, 1); - } - } - } - - /* - * java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory - * java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces - * java.naming.provider.url=localhost:1099 - * jnp.disableDiscovery=true - */ -} Copied: labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-tagme/src/java/org/jboss/labs/tagme/gwt/client/LabsDialogBox.java (from rev 4785, labs/jbosslabs/trunk/portal-extensions/forge-tagme/src/java/org/jboss/labs/tagme/gwt/client/LabsDialogBox.java) Modified: labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-tagme/src/java/org/jboss/labs/tagme/gwt/client/TagMe.java =================================================================== --- labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-tagme/src/java/org/jboss/labs/tagme/gwt/client/TagMe.java 2006-06-20 19:28:56 UTC (rev 4785) +++ labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-tagme/src/java/org/jboss/labs/tagme/gwt/client/TagMe.java 2006-06-20 19:38:10 UTC (rev 4786) @@ -114,7 +114,7 @@ Image image = new Image("/file-access/default/theme/images/but_tagme.gif"); image.setStyleName("tagme_btn"); - image.addClickListener(new TagMeShowPopupListener(path, user, clas)); + image.addClickListener(new TagMeShowPopupListener(path, user, clas, image)); return image; //return new Button("TagMe", new TagMeShowPopupListener(path, user, clas)); Modified: labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-tagme/src/java/org/jboss/labs/tagme/gwt/client/TagMeShowPopupListener.java =================================================================== --- labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-tagme/src/java/org/jboss/labs/tagme/gwt/client/TagMeShowPopupListener.java 2006-06-20 19:28:56 UTC (rev 4785) +++ labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-tagme/src/java/org/jboss/labs/tagme/gwt/client/TagMeShowPopupListener.java 2006-06-20 19:38:10 UTC (rev 4786) @@ -25,6 +25,7 @@ import java.util.Vector; import com.google.gwt.core.client.GWT; +import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; @@ -61,13 +62,16 @@ private Button saveBtn; private FlexTable suggTable; + + private Vector suggestionCheckboxes; - private Vector suggestionCheckboxes; + private Image parentButton; - public TagMeShowPopupListener(String path, String user, String clas) { + public TagMeShowPopupListener(String path, String user, String clas, Image parentButton) { this.path = path; this.currentUser = user; this.clas = clas; + this.parentButton = parentButton; } public TagMeShowPopupListener getMyself() { @@ -76,7 +80,7 @@ public void refreshSugestions() { suggestionCheckboxes = new Vector(); - + while (suggTable.getRowCount() > 0) { table.removeRow(0); } @@ -89,12 +93,12 @@ AsyncCallback callback = new AsyncCallback() { public void onSuccess(Object result) { - Vector vect = (Vector)result; - - int rowLen = (int)Math.sqrt(vect.size()); - + Vector vect = (Vector) result; + + int rowLen = (int) Math.sqrt(vect.size()); + for (int i = 0; i < vect.size(); i++) { - CheckBox chBox = new CheckBox((String)vect.get(i)); + CheckBox chBox = new CheckBox((String) vect.get(i)); suggTable.setWidget(i / rowLen, i % rowLen, chBox); suggestionCheckboxes.add(chBox); } @@ -182,7 +186,7 @@ // call AJAX methos, after that callback is going to be executed tagging.getTags(path, clas, callback); - + // refresh tags also refreshSugestions(); } @@ -223,7 +227,7 @@ refreshTags(); - final DialogBox dialog = new DialogBox(); + final LabsDialogBox dialog = new LabsDialogBox(); HorizontalPanel btnPanel = new HorizontalPanel(); this.saveBtn = new Button("Save", new TagMeClickListener(path, @@ -256,8 +260,7 @@ dialog.setText("TagMe!"); - dialog.setPopupPosition(sender.getAbsoluteLeft(), sender - .getAbsoluteTop()); + dialog.setPopupPosition(DOM.getAbsoluteLeft(parentButton.getElement()), DOM.getAbsoluteTop(parentButton.getElement())); dialog.show(); Modified: labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-theme/jbossForgeLayout.war/layouts/jbossForge.jsp =================================================================== --- labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-theme/jbossForgeLayout.war/layouts/jbossForge.jsp 2006-06-20 19:28:56 UTC (rev 4785) +++ labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-theme/jbossForgeLayout.war/layouts/jbossForge.jsp 2006-06-20 19:38:10 UTC (rev 4786) @@ -125,8 +125,13 @@ <div id="jbfPageFooter"> <div id="Copyright"> - JBoss is a registered trademark and servicemark of JBoss Inc. 2002-2005 JBoss Inc. All rights reserved.<br /> -Theme made by <a href="http://mamut.net.pl">Szimano</a> + <a href="http://www.redhat.com"><img src="http://www.jboss.com/jbosstheme/img/logo_rh_home.png" alt=" Red Hat" width="96" height="31" border="0" /></a> + <br /> + <br /> + © 2002-2006 Red Hat, Inc. All rights reserved. JBoss is a registered trademark of Red Hat, Inc. + <a href="http://www.jboss.com/privacy_policy">Privacy Policy</a><br /> + + Theme made by <a href="http://mamut.net.pl">Szimano</a> </div> </div> Modified: labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/WikiCommon.java =================================================================== --- labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/WikiCommon.java 2006-06-20 19:28:56 UTC (rev 4785) +++ labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/WikiCommon.java 2006-06-20 19:38:10 UTC (rev 4786) @@ -37,6 +37,7 @@ import org.jboss.mx.util.MBeanProxyExt; import org.jboss.mx.util.MBeanServerLocator; import org.jboss.wiki.exceptions.WikiManagementNotFoundException; +import org.jboss.wiki.management.EMailNotifier; import org.jboss.wiki.management.NotificationMsg; import org.jboss.wiki.management.WikiServiceMenagement; import org.jboss.wiki.plugins.DifferenceEngine; @@ -77,17 +78,20 @@ try { InitialContext context = new InitialContext(); - QueueSession sess = null; - Queue queue = null; + //QueueSession sess = null; + //Queue queue = null; + EMailNotifier notifer = null; try { - queue = (Queue) context.lookup("queue/wikiNotifications"); + /*queue = (Queue) context.lookup("queue/wikiNotifications"); QueueConnectionFactory factory = (QueueConnectionFactory) context .lookup("java:/ConnectionFactory"); sess = factory.createQueueConnection().createQueueSession( - false, QueueSession.AUTO_ACKNOWLEDGE); + false, QueueSession.AUTO_ACKNOWLEDGE);*/ - if (sess != null) { - + notifer = (EMailNotifier)context.lookup(EMailNotifier.class.getName()); + + //if (sess != null) { + if (notifer != null) { String notifs = page .getMetaDataProperty(WatchListPlugin.WATCH_PROPERTY); @@ -150,17 +154,18 @@ diffs + "<br /><hr />\n<br/>\nThis is notification of page: " + pageLink + "<br/>\n" + pageHtml.getContent(), page.getName(), fromEmail, pageLink); - ObjectMessage msg = sess.createObjectMessage(notifMsg); - sess.createSender(queue).send(msg); + //ObjectMessage msg = sess.createObjectMessage(notifMsg); + //sess.createSender(queue).send(msg); + notifer.sendNotification(notifMsg); } } else { log.error("Couldn't create queue session."); } } catch (CloneNotSupportedException e) { log.error(e); - } catch (JMSException e) { + }/* catch (JMSException e) { log.error(e); - } + }*/ } catch (NamingException e1) { log.error(e1); } Copied: labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/management/EMailNotifier.java (from rev 4785, labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/management/EMailNotifier.java) Copied: labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/jbosswiki/wiki-management/src/java/org/jboss/wiki/EMailNotifierSLSB.java (from rev 4785, labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-management/src/java/org/jboss/wiki/EMailNotifierSLSB.java) Modified: labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/jbosswiki/wiki-management/src/java/org/jboss/wiki/MailNotificationBean.java =================================================================== --- labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/jbosswiki/wiki-management/src/java/org/jboss/wiki/MailNotificationBean.java 2006-06-20 19:28:56 UTC (rev 4785) +++ labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/jbosswiki/wiki-management/src/java/org/jboss/wiki/MailNotificationBean.java 2006-06-20 19:38:10 UTC (rev 4786) @@ -19,7 +19,7 @@ * 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; +/*package org.jboss.wiki; import java.util.Date; @@ -102,4 +102,4 @@ } } -} +}*/ |
From: <jbo...@li...> - 2006-06-20 19:28:59
|
Author: dam...@jb... Date: 2006-06-20 15:28:56 -0400 (Tue, 20 Jun 2006) New Revision: 4785 Modified: labs/jbosslabs/branches/prod/jbosslabs/portal-extensions/ Log: Updating prod branch of labs to use the prod branch of shotoku. Property changes on: labs/jbosslabs/branches/prod/jbosslabs/portal-extensions ___________________________________________________________________ Name: svn:externals - shotoku http://anonsvn.labs.jboss.com/labs/shotoku/branches/qa + shotoku http://anonsvn.labs.jboss.com/labs/shotoku/branches/prod |
From: <jbo...@li...> - 2006-06-20 19:28:01
|
Author: dam...@jb... Date: 2006-06-20 15:27:58 -0400 (Tue, 20 Jun 2006) New Revision: 4784 Added: labs/shotoku/branches/prod/ Log: Branching QA to prod. Copied: labs/shotoku/branches/prod (from rev 4783, labs/shotoku/branches/qa) |
From: <jbo...@li...> - 2006-06-20 07:19:38
|
Author: mla...@jb... Date: 2006-06-20 03:19:31 -0400 (Tue, 20 Jun 2006) New Revision: 4783 Modified: labs/jbossweb/trunk/build.properties.default Log: Increment the current version number. Modified: labs/jbossweb/trunk/build.properties.default =================================================================== --- labs/jbossweb/trunk/build.properties.default 2006-06-20 05:22:41 UTC (rev 4782) +++ labs/jbossweb/trunk/build.properties.default 2006-06-20 07:19:31 UTC (rev 4783) @@ -12,8 +12,8 @@ # ----- Vesion Control Flags ----- version.major=1 version.minor=0 -version.build=0 -version.patch=GA +version.build=1 +version.patch=dev # ----- Vesion Control Flags ----- jboss.version.major=4 |
Author: bagerman Date: 2006-06-20 01:22:41 -0400 (Tue, 20 Jun 2006) New Revision: 4782 Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/AlphaMemory.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/ConstrainedIteratorFromPositionToTableStart.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/IteratorFromPositionToTableEnd.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/IteratorFromPositionToTableStart.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/RecordComparator.java Removed: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/BaseTableIterator.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/BaseTableReverseOrderIterator.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/ConstrainedFactTableIterator.java 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/LeapsWorkingMemory.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/TokenEvaluator.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/Table.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/TableIterator.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/TableRecord.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/TokenStack.java labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/util/TableIteratorTest.java labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/util/TableTest.java Log: JBRULES-316 Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/AlphaMemory.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/AlphaMemory.java 2006-06-20 02:13:42 UTC (rev 4781) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/AlphaMemory.java 2006-06-20 05:22:41 UTC (rev 4782) @@ -0,0 +1,32 @@ +package org.drools.leaps; + +import org.drools.WorkingMemory; +import org.drools.common.InternalFactHandle; +import org.drools.spi.FieldConstraint; +import org.drools.spi.Tuple; +import org.drools.util.IdentityMap; + +class AlphaMemory { + private IdentityMap alphaChecks = new IdentityMap( ); + + AlphaMemory() { + + } + + boolean checkAlpha( final FieldConstraint alpha, + final InternalFactHandle factHandle, + final Tuple tuple, + final WorkingMemory workingMemory ) { + Boolean ret = (Boolean) this.alphaChecks.get( factHandle ); + if (ret == null) { + ret = new Boolean( alpha.isAllowed( factHandle, tuple, workingMemory ) ); + this.alphaChecks.put( factHandle, ret ); + } + + return ret.booleanValue( ); + } + + boolean isAlphaBeenChecked(final InternalFactHandle factHandle){ + return this.alphaChecks != null && this.alphaChecks.containsKey( factHandle ); + } +} 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-06-20 02:13:42 UTC (rev 4781) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/FactTable.java 2006-06-20 05:22:41 UTC (rev 4782) @@ -125,7 +125,7 @@ // rest would be added to stack automatically final DefaultFactHandle startFactHandle = new DefaultFactHandle( workingMemory.getIdLastFireAllAt( ), new Object( ) ); - for (final Iterator it = this.tailIterator( startFactHandle, startFactHandle ); it.hasNext( );) { + for (final Iterator it = this.iteratorFromPositionToTableStart( startFactHandle, startFactHandle ); it.hasNext( );) { final LeapsFactHandle handle = (LeapsFactHandle) it.next( ); workingMemory.pushTokenOnStack( handle, new Token( workingMemory, handle, Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsWorkingMemory.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsWorkingMemory.java 2006-06-20 02:13:42 UTC (rev 4781) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsWorkingMemory.java 2006-06-20 05:22:41 UTC (rev 4782) @@ -218,8 +218,9 @@ } tuple.removeBlockingNotFactHandle( assembly.getIndex( ) ); - TokenEvaluator.evaluateNotCondition( new LeapsFactHandle( factHandle.getRecency( ) + 1, - new Object( ) ), + TokenEvaluator.evaluateNotCondition( (LeapsFactHandle) factHandle, +// TokenEvaluator.evaluateNotCondition( new LeapsFactHandle( factHandle.getRecency( ) + 1, +// new Object( ) ), assembly.getIndex( ), tuple, this ); @@ -235,8 +236,9 @@ tuple ); } tuple.removeExistsFactHandle( assembly.getIndex( ) ); - TokenEvaluator.evaluateExistsCondition( new LeapsFactHandle( factHandle.getRecency( ) + 1, - null ), + TokenEvaluator.evaluateExistsCondition( (LeapsFactHandle)factHandle, +// TokenEvaluator.evaluateExistsCondition( new LeapsFactHandle( factHandle.getRecency( ) + 1, +// null ), assembly.getIndex( ), tuple, this ); Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/TokenEvaluator.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/TokenEvaluator.java 2006-06-20 02:13:42 UTC (rev 4781) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/TokenEvaluator.java 2006-06-20 05:22:41 UTC (rev 4782) @@ -39,25 +39,26 @@ * @throws Exception * @throws InvalidRuleException */ - final static protected void evaluate(final Token token) throws NoMatchesFoundException, - InvalidRuleException { - final LeapsWorkingMemory workingMemory = (LeapsWorkingMemory) token.getWorkingMemory(); - final LeapsRule leapsRule = token.getCurrentRuleHandle().getLeapsRule(); + final static protected void evaluate( final Token token ) + throws NoMatchesFoundException, InvalidRuleException { + final LeapsWorkingMemory workingMemory = (LeapsWorkingMemory) token.getWorkingMemory( ); + final LeapsRule leapsRule = token.getCurrentRuleHandle( ).getLeapsRule( ); // sometimes there is no normal conditions, only not and exists - final int numberOfColumns = leapsRule.getNumberOfColumns(); - // if (numberOfColumns > 0) { - final int dominantFactPosition = token.getCurrentRuleHandle().getDominantPosition(); - final InternalFactHandle dominantFactHandle = token.getDominantFactHandle(); - if ( leapsRule.getColumnConstraintsAtPosition( dominantFactPosition ).isAllowedAlpha( dominantFactHandle, - token, - workingMemory ) ) { + final int numberOfColumns = leapsRule.getNumberOfColumns( ); + // if (numberOfColumns > 0) { + final int dominantFactPosition = token.getCurrentRuleHandle( ) + .getDominantPosition( ); + final InternalFactHandle dominantFactHandle = token.getDominantFactHandle( ); + if (leapsRule.getColumnConstraintsAtPosition( dominantFactPosition ) + .isAllowedAlpha( dominantFactHandle, token, workingMemory )) { final Class dominantClass = leapsRule.getColumnClassObjectTypeAtPosition( dominantFactPosition ); final TableIterator[] iterators = new TableIterator[numberOfColumns]; // getting iterators first - for ( int i = 0; i < numberOfColumns; i++ ) { - if ( i == dominantFactPosition ) { + for (int i = 0; i < numberOfColumns; i++) { + if (i == dominantFactPosition) { iterators[i] = Table.singleItemIterator( dominantFactHandle ); - } else { + } + else { final Class columnClass = leapsRule.getColumnClassObjectTypeAtPosition( i ); final ColumnConstraints constraints = leapsRule.getColumnConstraintsAtPosition( i ); final FactTable factTable = workingMemory.getFactTable( columnClass ); @@ -65,15 +66,18 @@ new Object( ) ) : (LeapsFactHandle) dominantFactHandle; // - if ( i > 0 && constraints.isAlphaPresent() ) { - iterators[i] = factTable.tailConstrainedIterator( workingMemory, - constraints, - startFactHandle, - (token.isResume() ? (LeapsFactHandle) token.get( i ) : startFactHandle) ); - } else { - iterators[i] = factTable.tailIterator( startFactHandle, - (token.isResume() ? (LeapsFactHandle) token.get( i ) : startFactHandle) ); + if (i > 0 && constraints.isAlphaPresent( )) { + iterators[i] = factTable.constrainedIteratorFromPositionToTableStart( workingMemory, + constraints, + startFactHandle, + ( token.isResume( ) ? (LeapsFactHandle) token.get( i ) + : startFactHandle ) ); } + else { + iterators[i] = factTable.iteratorFromPositionToTableStart( startFactHandle, + ( token.isResume( ) ? (LeapsFactHandle) token.get( i ) + : startFactHandle ) ); + } } } @@ -81,25 +85,28 @@ // check if we resume and any starting facts disappeared than we // do not do skip on resume boolean doReset = false; - boolean skip = token.isResume(); + boolean skip = token.isResume( ); TableIterator currentIterator; - for ( int i = 0; i < numberOfColumns; i++ ) { + for (int i = 0; i < numberOfColumns; i++) { currentIterator = iterators[i]; // check if one of them is empty and immediate return - if ( currentIterator.isEmpty() ) { - throw new NoMatchesFoundException(); - } else { - if ( !doReset ) { - if ( skip && currentIterator.hasNext() && !currentIterator.peekNext().equals( token.get( i ) ) ) { - // we tried to resume but our fact handle at marker disappear - // no need to resume just reset all interators positioned - // at the marker where we stoped last time + if (currentIterator.isEmpty( )) { + throw new NoMatchesFoundException( ); + } + else { + if (!doReset) { + if (skip && currentIterator.hasNext( ) + && !currentIterator.peekNext( ).equals( token.get( i ) )) { + // we tried to resume but our fact handle at marker + // disappear no need to resume just reset all interators + // positioned at the marker where we stoped last time skip = false; doReset = true; } - } else { - currentIterator.reset(); } + else { + currentIterator.reset( ); + } } } @@ -108,53 +115,59 @@ int jj = 0; boolean done = false; final int stopIteratingCount = numberOfColumns - 1; - while ( !done ) { + while (!done) { currentIterator = iterators[jj]; - if ( !currentIterator.hasNext() ) { - if ( jj == 0 ) { + if (!currentIterator.hasNext( )) { + if (jj == 0) { done = true; - } else { - // nothing for this column, go back and check next + } + else { + // nothing for this column, go back and check next // on the one level up in nested loop - currentIterator.reset(); + currentIterator.reset( ); jj = jj - 1; - if ( skip ) { + if (skip) { skip = false; } } - } else { - final LeapsFactHandle currentFactHandle = (LeapsFactHandle) currentIterator.next(); + } + else { + final LeapsFactHandle currentFactHandle = (LeapsFactHandle) currentIterator.next( ); // check if match found we need to check only beta for // dominant fact // alpha was already checked boolean localMatch = false; - if ( !skip ) { - if ( jj != 0 || jj == dominantFactPosition ) { - localMatch = leapsRule.getColumnConstraintsAtPosition( jj ).isAllowedBeta( currentFactHandle, - token, - workingMemory ); - } else { - localMatch = leapsRule.getColumnConstraintsAtPosition( jj ).isAllowed( currentFactHandle, - token, - workingMemory ); + if (!skip) { + if (jj != 0 || jj == dominantFactPosition) { + localMatch = leapsRule.getColumnConstraintsAtPosition( jj ) + .isAllowedBeta( currentFactHandle, + token, + workingMemory ); } + else { + localMatch = leapsRule.getColumnConstraintsAtPosition( jj ) + .isAllowed( currentFactHandle, + token, + workingMemory ); + } } - if ( localMatch || skip ) { - token.set( jj, - currentFactHandle ); + if (localMatch || skip) { + token.set( jj, currentFactHandle ); // start iteratating next iterator or for the last // one check negative conditions and fire consequence - if ( jj == stopIteratingCount ) { - if ( !skip ) { - if ( processAfterAllPositiveConstraintOk( token.getTuple(), - leapsRule, - workingMemory ) ) { + if (jj == stopIteratingCount) { + if (!skip) { + if (processAfterAllPositiveConstraintOk( token.getTuple( ), + leapsRule, + workingMemory )) { return; } - } else { + } + else { skip = false; } - } else { + } + else { jj = jj + 1; } } @@ -162,7 +175,7 @@ } } // nothing was found. inform caller about it - throw new NoMatchesFoundException(); + throw new NoMatchesFoundException( ); } /** @@ -215,13 +228,12 @@ * @return * @throws Exception */ - private final static boolean evaluateEvalConditions(final LeapsRule leapsRule, - final LeapsTuple tuple, - final LeapsWorkingMemory workingMemory) { - final EvalCondition[] evals = leapsRule.getEvalConditions(); - for ( int i = 0; i < evals.length; i++ ) { - if ( !evals[i].isAllowed( tuple, - workingMemory ) ) { + private final static boolean evaluateEvalConditions( final LeapsRule leapsRule, + final LeapsTuple tuple, + final LeapsWorkingMemory workingMemory ) { + final EvalCondition[] evals = leapsRule.getEvalConditions( ); + for (int i = 0; i < evals.length; i++) { + if (!evals[i].isAllowed( tuple, workingMemory )) { return false; } } @@ -237,26 +249,23 @@ * @return success * @throws Exception */ - final static void evaluateNotConditions(final LeapsTuple tuple, - final LeapsRule rule, - final LeapsWorkingMemory workingMemory) { - final ColumnConstraints[] not = rule.getNotColumnConstraints(); - for ( int i = 0, length = not.length; i < length; i++ ) { + final static void evaluateNotConditions( final LeapsTuple tuple, + final LeapsRule rule, + final LeapsWorkingMemory workingMemory ) { + final ColumnConstraints[] not = rule.getNotColumnConstraints( ); + for (int i = 0, length = not.length; i < length; i++) { final ColumnConstraints constraint = not[i]; // scan table starting at start fact handle - final TableIterator tableIterator = workingMemory.getFactTable( constraint.getClassType() ).reverseOrderIterator(); + final TableIterator tableIterator = workingMemory.getFactTable( constraint.getClassType( ) ) + .reverseOrderIterator( ); // stops if exists boolean done = false; - while ( !done && tableIterator.hasNext() ) { - final LeapsFactHandle factHandle = (LeapsFactHandle) tableIterator.next(); + while (!done && tableIterator.hasNext( )) { + final LeapsFactHandle factHandle = (LeapsFactHandle) tableIterator.next( ); // check constraint conditions - if ( constraint.isAllowed( factHandle, - tuple, - workingMemory ) ) { - tuple.setBlockingNotFactHandle( factHandle, - i ); - factHandle.addNotTuple( tuple, - i ); + if (constraint.isAllowed( factHandle, tuple, workingMemory )) { + tuple.setBlockingNotFactHandle( factHandle, i ); + factHandle.addNotTuple( tuple, i ); done = true; } } @@ -273,26 +282,23 @@ * @param rule * @param workingMemory */ - final static void evaluateNotCondition(final LeapsFactHandle startFactHandle, - final int index, - final LeapsTuple tuple, - final LeapsWorkingMemory workingMemory) { - final LeapsRule rule = tuple.getLeapsRule(); + final static void evaluateNotCondition( final LeapsFactHandle startFactHandle, + final int index, + final LeapsTuple tuple, + final LeapsWorkingMemory workingMemory ) { + final LeapsRule rule = tuple.getLeapsRule( ); // scan table starting at start fact handle - final ColumnConstraints constraint = rule.getNotColumnConstraints()[index]; - final TableIterator tableIterator = workingMemory.getFactTable( constraint.getClassType() ).headReverseOrderIterator( startFactHandle ); + final ColumnConstraints constraint = rule.getNotColumnConstraints( )[index]; + final TableIterator tableIterator = workingMemory.getFactTable( constraint.getClassType( ) ) + .iteratorFromPositionToTableEnd( startFactHandle ); // stops if exists boolean done = false; - while ( !done && tableIterator.hasNext() ) { - final LeapsFactHandle factHandle = (LeapsFactHandle) tableIterator.next(); + while (!done && tableIterator.hasNext( )) { + final LeapsFactHandle factHandle = (LeapsFactHandle) tableIterator.next( ); // check constraint conditions - if ( constraint.isAllowed( factHandle, - tuple, - workingMemory ) ) { - tuple.setBlockingNotFactHandle( factHandle, - index ); - factHandle.addNotTuple( tuple, - index ); + if (constraint.isAllowed( factHandle, tuple, workingMemory )) { + tuple.setBlockingNotFactHandle( factHandle, index ); + factHandle.addNotTuple( tuple, index ); done = true; } } @@ -305,20 +311,21 @@ * @param memory * @throws Exception */ - private final static void evaluateExistsConditions(final LeapsTuple tuple, - final LeapsRule rule, - final LeapsWorkingMemory workingMemory) { - final ColumnConstraints[] exists = rule.getExistsColumnConstraints(); - for ( int i = 0, length = exists.length; i < length; i++ ) { + private final static void evaluateExistsConditions( final LeapsTuple tuple, + final LeapsRule rule, + final LeapsWorkingMemory workingMemory ) { + final ColumnConstraints[] exists = rule.getExistsColumnConstraints( ); + for (int i = 0, length = exists.length; i < length; i++) { final ColumnConstraints constraint = exists[i]; // scan table starting at start fact handle - final TableIterator tableIterator = workingMemory.getFactTable( constraint.getClassType() ).reverseOrderIterator(); + final TableIterator tableIterator = workingMemory.getFactTable( constraint.getClassType( ) ) + .reverseOrderIterator( ); // stop if exists boolean done = false; - while ( !done && tableIterator.hasNext() ) { - final LeapsFactHandle factHandle = (LeapsFactHandle) tableIterator.next(); + while (!done && tableIterator.hasNext( )) { + final LeapsFactHandle factHandle = (LeapsFactHandle) tableIterator.next( ); // check constraint conditions - if ( constraint.isAllowed( factHandle, + if (constraint.isAllowed( factHandle, tuple, workingMemory ) ) { tuple.setExistsFactHandle( factHandle, @@ -341,28 +348,25 @@ * @param rule * @param workingMemory */ - final static void evaluateExistsCondition(final LeapsFactHandle startFactHandle, - final int index, - final LeapsTuple tuple, - final LeapsWorkingMemory workingMemory) { - final LeapsRule rule = tuple.getLeapsRule(); + final static void evaluateExistsCondition( final LeapsFactHandle startFactHandle, + final int index, + final LeapsTuple tuple, + final LeapsWorkingMemory workingMemory ) { + final LeapsRule rule = tuple.getLeapsRule( ); // scan table starting at start fact handle - final ColumnConstraints constraint = rule.getExistsColumnConstraints()[index]; - final TableIterator tableIterator = workingMemory.getFactTable( constraint.getClassType() ).headReverseOrderIterator( startFactHandle ); + final ColumnConstraints constraint = rule.getExistsColumnConstraints( )[index]; + final TableIterator tableIterator = workingMemory.getFactTable( constraint.getClassType( ) ) + .iteratorFromPositionToTableEnd( startFactHandle ); // stop if exists boolean done = false; - while ( !done && tableIterator.hasNext() ) { - final LeapsFactHandle factHandle = (LeapsFactHandle) tableIterator.next(); + while (!done && tableIterator.hasNext( )) { + final LeapsFactHandle factHandle = (LeapsFactHandle) tableIterator.next( ); // check constraint conditions - if ( constraint.isAllowed( factHandle, - tuple, - workingMemory ) ) { - tuple.setExistsFactHandle( factHandle, - index ); - factHandle.addExistsTuple( tuple, - index ); + if (constraint.isAllowed( factHandle, tuple, workingMemory )) { + tuple.setExistsFactHandle( factHandle, index ); + factHandle.addExistsTuple( tuple, index ); done = true; } } } -} \ No newline at end of file +} Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/BaseTableIterator.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/BaseTableIterator.java 2006-06-20 02:13:42 UTC (rev 4781) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/BaseTableIterator.java 2006-06-20 05:22:41 UTC (rev 4782) @@ -1,109 +0,0 @@ -package org.drools.leaps.util; - -/* - * Copyright 2005 JBoss Inc - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.util.NoSuchElementException; - -/** - * Leaps specific iterator for leaps tables. relies on leaps table double link - * list structure for navigation - * - * @author Alexander Bagerman - * - */ -public class BaseTableIterator - implements - TableIterator { - /** - * interator that was not initialized as "empty" iterator (one or another - * record was submitted to constractor) will set it to false - */ - private TableRecord firstRecord; - - private TableRecord lastRecord; - - private TableRecord currentRecord; - - private TableRecord nextRecord; - - /** - * constracts an leaps iterator to iterate over a single record. Used for - * Dominant fact dimention iteration - * - * @param record - * to iterate over - */ - - /** - * constracts an leaps iterator to iterate over a single record. Used for - * Dominant fact dimention iteration - * - * @param record - * to iterate over - */ - protected BaseTableIterator(final TableRecord record) { - this.firstRecord = record; - this.lastRecord = record; - this.currentRecord = null; - this.nextRecord = this.firstRecord; - } - - protected BaseTableIterator(final TableRecord startRecord, - final TableRecord currentRecord, - final TableRecord lastRecord) { - this.firstRecord = startRecord; - this.nextRecord = currentRecord; - this.lastRecord = lastRecord; - this.currentRecord = null; - } - - public boolean isEmpty() { - return this.firstRecord == null; - } - - public void reset() { - this.currentRecord = null; - this.nextRecord = this.firstRecord; - } - - public boolean hasNext() { - return this.nextRecord != null; - } - - public Object next() { - this.currentRecord = this.nextRecord; - if ( this.currentRecord != null ) { - // need to check on last record because we iterate of subset of - // all data limited by last record - if ( this.currentRecord == this.lastRecord ) { - this.nextRecord = null; - } else { - this.nextRecord = this.currentRecord.right; - } - } else { - throw new NoSuchElementException( "No more elements to return" ); - } - return this.currentRecord.object; - } - - public Object peekNext() { - return this.nextRecord.object; - } - - public void remove() { - } -} \ No newline at end of file Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/BaseTableReverseOrderIterator.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/BaseTableReverseOrderIterator.java 2006-06-20 02:13:42 UTC (rev 4781) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/BaseTableReverseOrderIterator.java 2006-06-20 05:22:41 UTC (rev 4782) @@ -1,113 +0,0 @@ -package org.drools.leaps.util; - -/* - * Copyright 2005 JBoss Inc - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.util.NoSuchElementException; - -/** - * Leaps specific iterator for leaps tables. relies on leaps table double link - * list structure for navigation - * - * @author Alexander Bagerman - * - */ -public class BaseTableReverseOrderIterator - implements - TableIterator { - /** - * interator that was not initialized as "empty" iterator (one or another - * record was submitted to constractor) will set it to false - */ - private TableRecord firstRecord; - - private TableRecord lastRecord; - - private TableRecord currentRecord; - - private TableRecord nextRecord; - - /** - * constracts an leaps iterator to iterate over a single record. Used for - * Dominant fact dimention iteration - * - * @param record - * to iterate over - */ - - /** - * constracts an leaps iterator to iterate over a single record. Used for - * Dominant fact dimention iteration - * - * @param record - * to iterate over - */ - protected BaseTableReverseOrderIterator(final TableRecord record) { - this.firstRecord = record; - this.lastRecord = record; - this.currentRecord = null; - this.nextRecord = this.firstRecord; - } - - protected BaseTableReverseOrderIterator(final TableRecord startRecord, - final TableRecord currentRecord, - final TableRecord lastRecord) { - this.firstRecord = startRecord; - this.nextRecord = currentRecord; - this.lastRecord = lastRecord; - this.currentRecord = null; - } - - public boolean isEmpty() { - return this.firstRecord == null; - } - - public void reset() { - this.currentRecord = null; - this.nextRecord = this.firstRecord; - } - - public boolean hasNext() { - return this.nextRecord != null; - } - - public Object next() { - this.currentRecord = this.nextRecord; - if ( this.currentRecord != null ) { - // need to check on last record because we iterate of subset of - // all data limited by last record - if ( this.currentRecord == this.lastRecord ) { - this.nextRecord = null; - } else { - this.nextRecord = this.currentRecord.left; - } - } else { - throw new NoSuchElementException( "No more elements to return" ); - } - return this.currentRecord.object; - } - - public Object current() { - return this.currentRecord.object; - } - - public Object peekNext() { - return this.nextRecord.object; - } - - public void remove() { - } -} \ No newline at end of file Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/ConstrainedFactTableIterator.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/ConstrainedFactTableIterator.java 2006-06-20 02:13:42 UTC (rev 4781) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/ConstrainedFactTableIterator.java 2006-06-20 05:22:41 UTC (rev 4782) @@ -1,161 +0,0 @@ -package org.drools.leaps.util; - -/* - * Copyright 2005 JBoss Inc - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.util.NoSuchElementException; - -import org.drools.WorkingMemory; -import org.drools.common.InternalFactHandle; -import org.drools.leaps.ColumnConstraints; - -/** - * this class is for multi pass iterations to sort out facts that do not satisfy - * alpha nodes - * - * previous to the left - * next to the right - * - * @author Alexander Bagerman - * - */ -public class ConstrainedFactTableIterator - implements - TableIterator { - private boolean finishInitialPass = false; - - final WorkingMemory workingMemory; - - final ColumnConstraints constraints; - - private int size = 0; - - private TableRecord firstRecord; - - private TableRecord lastRecord; - - private TableRecord currentRecord; - - private TableRecord nextRecord; - - private TableRecord currentTableRecord; - - private TableRecord lastTableRecord; - - protected ConstrainedFactTableIterator(final WorkingMemory workingMemory, - final ColumnConstraints constraints, - final TableRecord startRecord, - final TableRecord currentRecord, - final TableRecord lastRecord) { - this.workingMemory = workingMemory; - this.constraints = constraints; - this.lastTableRecord = lastRecord; - this.currentTableRecord = startRecord; - boolean done = false; - boolean reachCurrentRecord = false; - while ( !done && this.currentTableRecord != null && !this.finishInitialPass ) { - if ( !reachCurrentRecord && this.currentTableRecord == currentRecord ) { - reachCurrentRecord = true; - } else { - if ( this.constraints.isAllowedAlpha( (InternalFactHandle) this.currentTableRecord.object, - null, - this.workingMemory ) ) { - this.add( this.currentTableRecord.object ); - } - if ( reachCurrentRecord && !this.isEmpty() ) { - done = true; - } - if ( this.currentTableRecord == this.lastTableRecord ) { - this.finishInitialPass = true; - } - this.currentTableRecord = this.currentTableRecord.right; - } - } - // - this.nextRecord = this.lastRecord; - } - - private void add(final Object object) { - final TableRecord record = new TableRecord( object ); - if ( this.firstRecord == null ) { - this.firstRecord = record; - this.lastRecord = record; - } else { - this.lastRecord.right = record; - record.left = this.lastRecord; - this.lastRecord = record; - } - this.size++; - } - - public boolean isEmpty() { - return this.firstRecord == null; - } - - public void reset() { - this.currentRecord = null; - this.nextRecord = this.firstRecord; - } - - public Object next() { - this.currentRecord = this.nextRecord; - if ( this.currentRecord != null ) { - this.nextRecord = this.currentRecord.right; - } else { - throw new NoSuchElementException( "No more elements to return" ); - } - return this.currentRecord.object; - } - - public Object current() { - return this.currentRecord.object; - } - - public Object peekNext() { - return this.nextRecord.object; - } - - public void remove() { - } - - public boolean hasNext() { - if ( !this.finishInitialPass ) { - if ( this.nextRecord == null ) { - boolean found = false; - while ( !found && this.currentTableRecord != null ) { - if ( this.constraints.isAllowedAlpha( (InternalFactHandle) this.currentTableRecord.object, - null, - this.workingMemory ) ) { - this.add( this.currentTableRecord.object ); - found = true; - } - if ( this.currentTableRecord == this.lastTableRecord ) { - this.finishInitialPass = true; - } - this.currentTableRecord = this.currentTableRecord.right; - } - // - if ( found ) { - this.nextRecord = this.lastRecord; - } - return found; - } - return true; - } else { - return this.nextRecord != null; - } - } -} \ No newline at end of file Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/ConstrainedIteratorFromPositionToTableStart.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/ConstrainedIteratorFromPositionToTableStart.java 2006-06-20 02:13:42 UTC (rev 4781) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/ConstrainedIteratorFromPositionToTableStart.java 2006-06-20 05:22:41 UTC (rev 4782) @@ -0,0 +1,115 @@ +package org.drools.leaps.util; + +/* + * Copyright 2005 JBoss Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import org.drools.WorkingMemory; +import org.drools.common.InternalFactHandle; +import org.drools.leaps.ColumnConstraints; + +/** + * this class is for multi pass iterations to sort out facts that do not satisfy + * alpha nodes + * + * previous to the left + * next to the right + * + * @author Alexander Bagerman + * + */ +public class ConstrainedIteratorFromPositionToTableStart extends IteratorFromPositionToTableStart { + private boolean finishInitialPass = false; + + final WorkingMemory workingMemory; + + final ColumnConstraints constraints; + + private TableRecord currentTableRecord; + + protected ConstrainedIteratorFromPositionToTableStart(final WorkingMemory workingMemory, + final ColumnConstraints constraints, + final TableRecord startRecord, + final TableRecord currentRecord) { + super( null ); + this.workingMemory = workingMemory; + this.constraints = constraints; + this.currentTableRecord = startRecord; + boolean done = false; + boolean reachCurrentRecord = false; + while (!done && this.currentTableRecord != null && !this.finishInitialPass) { + if (!reachCurrentRecord && this.currentTableRecord == currentRecord) { + reachCurrentRecord = true; + } + else { + if (this.constraints.isAllowedAlpha( (InternalFactHandle) this.currentTableRecord.object, + null, + this.workingMemory )) { + this.add( this.currentTableRecord.object ); + } + if (reachCurrentRecord && !this.isEmpty( )) { + done = true; + } + if (this.currentTableRecord.right == null) { + this.finishInitialPass = true; + } + this.currentTableRecord = this.currentTableRecord.right; + } + } + } + + private void add( final Object object ) { + final TableRecord record = new TableRecord( object ); + if (this.firstRecord == null) { + this.firstRecord = record; + this.currentRecord = record; + } + else { + this.currentRecord.right = record; + record.left = this.currentRecord; + this.currentRecord = record; + } + + this.nextRecord = this.currentRecord; + } + + public boolean hasNext() { + if (!this.finishInitialPass) { + if (this.nextRecord == null) { + boolean found = false; + while (!found && this.currentTableRecord != null) { + if (this.constraints.isAllowedAlpha( (InternalFactHandle) this.currentTableRecord.object, + null, + this.workingMemory )) { + this.add( this.currentTableRecord.object ); + found = true; + } + if (this.currentTableRecord == null) { + this.finishInitialPass = true; + } + this.currentTableRecord = this.currentTableRecord.right; + } + + return found; + } + else { + return true; + } + } + else { + return super.hasNext( ); + } + } +} Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/IteratorFromPositionToTableEnd.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/IteratorFromPositionToTableEnd.java 2006-06-20 02:13:42 UTC (rev 4781) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/IteratorFromPositionToTableEnd.java 2006-06-20 05:22:41 UTC (rev 4782) @@ -0,0 +1,63 @@ +package org.drools.leaps.util; + +/* + * Copyright 2005 JBoss Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.util.NoSuchElementException; + +/** + * Leaps specific iterator for leaps tables. relies on leaps table double link + * list structure for navigation + * + * @author Alexander Bagerman + * + */ +public class IteratorFromPositionToTableEnd extends IteratorFromPositionToTableStart { + /** + * @see IteratorFromPositionToTableStart + */ + protected IteratorFromPositionToTableEnd(final TableRecord record) { + super( record ); + } + + /** + * @see IteratorFromPositionToTableStart + */ + protected IteratorFromPositionToTableEnd(final TableRecord startRecord, + final TableRecord currentRecord) { + super( startRecord, currentRecord ); + } + + /** + * the difference here is that we are going to the different direction that + * base class next() method + * + * @see IteratorFromPositionToTableStart + * + */ + + public Object next() { + this.currentRecord = this.nextRecord; + if (this.currentRecord != null) { + this.nextRecord = this.currentRecord.left; + } + else { + throw new NoSuchElementException( "No more elements to return" ); + } + return this.currentRecord.object; + } + +} Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/IteratorFromPositionToTableStart.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/IteratorFromPositionToTableStart.java 2006-06-20 02:13:42 UTC (rev 4781) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/IteratorFromPositionToTableStart.java 2006-06-20 05:22:41 UTC (rev 4782) @@ -0,0 +1,90 @@ +package org.drools.leaps.util; + +/* + * Copyright 2005 JBoss Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.util.NoSuchElementException; + +/** + * Leaps specific iterator for leaps tables. relies on leaps table double link + * list structure for navigation + * + * @author Alexander Bagerman + * + */ +public class IteratorFromPositionToTableStart implements TableIterator { + /** + * interator that was not initialized as "empty" iterator (one or another + * record was submitted to constractor) will set it to false + */ + TableRecord firstRecord; + + TableRecord currentRecord; + + TableRecord nextRecord; + + /** + * constracts an leaps iterator to iterate over a single record. Used for + * Dominant fact dimention iteration + * + * @param record + * to iterate over + */ + + protected IteratorFromPositionToTableStart(final TableRecord record) { + this.firstRecord = record; + this.currentRecord = null; + this.nextRecord = this.firstRecord; + } + + protected IteratorFromPositionToTableStart(final TableRecord startRecord, + final TableRecord currentRecord) { + this.firstRecord = startRecord; + this.nextRecord = currentRecord; + this.currentRecord = null; + } + + public boolean isEmpty() { + return this.firstRecord == null; + } + + public void reset() { + this.currentRecord = null; + this.nextRecord = this.firstRecord; + } + + public boolean hasNext() { + return this.nextRecord != null; + } + + public Object next() { + this.currentRecord = this.nextRecord; + if (this.currentRecord != null) { + this.nextRecord = this.currentRecord.right; + } + else { + throw new NoSuchElementException( "No more elements to return" ); + } + return this.currentRecord.object; + } + + public Object peekNext() { + return this.nextRecord.object; + } + + public void remove() { + } +} Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/RecordComparator.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/RecordComparator.java 2006-06-20 02:13:42 UTC (rev 4781) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/RecordComparator.java 2006-06-20 05:22:41 UTC (rev 4782) @@ -0,0 +1,43 @@ +package org.drools.leaps.util; + +/* + * Copyright 2005 JBoss Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +import java.io.Serializable; +import java.util.Comparator; + +/** + * this class wraps object comparator to sort records holding given objects in + * a list + * + * @author Alexander Bagerman + * + */ + +class RecordComparator implements Comparator, Serializable { + private Comparator objectComparator; + + RecordComparator(Comparator objectComparator) { + this.objectComparator = objectComparator; + } + + public int compare( Object record1, Object record2 ) { + return this.objectComparator.compare( ( (TableRecord) record1 ).object, + ( (TableRecord) record2 ).object ); + } + +} Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/Table.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/Table.java 2006-06-20 02:13:42 UTC (rev 4781) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/Table.java 2006-06-20 05:22:41 UTC (rev 4782) @@ -20,27 +20,26 @@ import java.util.Comparator; import java.util.Iterator; import java.util.NoSuchElementException; -import java.util.SortedMap; -import java.util.TreeMap; +import java.util.TreeSet; import org.drools.WorkingMemory; import org.drools.leaps.ColumnConstraints; /** + * double linked list structure to store objects in the ordered list + * and iterate over the list for leaps * * @author Alexander Bagerman * */ -public class Table - implements - Serializable { +public class Table implements Serializable { /** * */ private static final long serialVersionUID = 2614082619270512055L; - private final TreeMap map; + private final TreeSet set; protected TableRecord headRecord; @@ -51,63 +50,57 @@ private int count = 0; public Table(final Comparator comparator) { - this.map = new TreeMap( comparator ); + this.set = new TreeSet( new RecordComparator(comparator) ); } protected void clear() { this.headRecord = new TableRecord( null ); this.empty = true; this.count = 0; - this.map.clear(); + this.set.clear( ); } /** * @param object * to add */ - public void add(final Object object) { - boolean foundEqualObject = false; + public void add( final Object object ) { final TableRecord newRecord = new TableRecord( object ); - if ( this.empty ) { + if (this.empty) { this.headRecord = newRecord; this.empty = false; - } else { - final SortedMap bufMap = this.map.headMap( object ); + } + else { try { // check on first key should work faster than check on empty // but logically we check on empty // if map empty it will throw exception - bufMap.firstKey(); - - // if ( !bufMap.isEmpty() ) { - final TableRecord bufRec = (TableRecord) this.map.get( bufMap.lastKey() ); - if ( bufRec.right != null ) { + final TableRecord bufRec = (TableRecord) this.set.headSet( newRecord ) + .last( ); + if (bufRec.right != null) { bufRec.right.left = newRecord; } newRecord.right = bufRec.right; bufRec.right = newRecord; newRecord.left = bufRec; - } //else { - catch ( final NoSuchElementException nsee ) { + } + catch (final NoSuchElementException nsee) { // means map is empty this.headRecord.left = newRecord; newRecord.right = this.headRecord; this.headRecord = newRecord; } } - if ( !foundEqualObject ) { - // check if the new record was added at the end of the list - // and assign new value to the tail record - if ( newRecord.right == null ) { - this.tailRecord = newRecord; - } - // - this.count++; - // - this.map.put( object, - newRecord ); + // check if the new record was added at the end of the list + // and assign new value to the tail record + if (newRecord.right == null) { + this.tailRecord = newRecord; } + // + this.count++; + // + this.set.add( newRecord ); } /** @@ -116,39 +109,46 @@ * @param object * to remove from the table */ - public void remove(final Object object) { - if ( !this.empty ) { - final TableRecord record = (TableRecord) this.map.get( object ); + public void remove( final Object object ) { + if (!this.empty) { + try { + final TableRecord record = (TableRecord) this.set.tailSet( new TableRecord( object ) ) + .first( ); - if ( record != null ) { - if ( record == this.headRecord ) { - if ( record.right != null ) { - this.headRecord = record.right; - this.headRecord.left = null; - } else { - // single element in table being valid - // table is empty now - this.headRecord = new TableRecord( null ); - this.tailRecord = this.headRecord; - this.empty = true; + if (record != null) { + if (record == this.headRecord) { + if (record.right != null) { + this.headRecord = record.right; + this.headRecord.left = null; + } + else { + // ... [truncated message content] |
From: <jbo...@li...> - 2006-06-20 02:13:54
|
Author: mic...@jb... Date: 2006-06-19 22:13:42 -0400 (Mon, 19 Jun 2006) New Revision: 4781 Added: labs/jbossrules/trunk/documentation/training/developers-course/Module 4 - Rule Engine Concepts 2.odp Log: Added: labs/jbossrules/trunk/documentation/training/developers-course/Module 4 - Rule Engine Concepts 2.odp =================================================================== (Binary files differ) Property changes on: labs/jbossrules/trunk/documentation/training/developers-course/Module 4 - Rule Engine Concepts 2.odp ___________________________________________________________________ Name: svn:mime-type + application/octet-stream |
Author: szimano Date: 2006-06-19 14:24:23 -0400 (Mon, 19 Jun 2006) New Revision: 4780 Added: labs/jbosslabs/trunk/portal-extensions/forge-tagme/src/java/org/jboss/labs/tagme/gwt/client/LabsDialogBox.java Modified: labs/jbosslabs/trunk/portal-extensions/forge-tagme/src/java/org/jboss/labs/tagme/gwt/client/TagMe.java labs/jbosslabs/trunk/portal-extensions/forge-tagme/src/java/org/jboss/labs/tagme/gwt/client/TagMeShowPopupListener.java labs/jbosslabs/trunk/portal-extensions/forge-theme/jbossForgeLayout.war/layouts/jbossForge.jsp Log: tagme hacks to make it work under firefox JBLAB-674 redhat footer in labs Added: labs/jbosslabs/trunk/portal-extensions/forge-tagme/src/java/org/jboss/labs/tagme/gwt/client/LabsDialogBox.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-tagme/src/java/org/jboss/labs/tagme/gwt/client/LabsDialogBox.java 2006-06-19 09:12:04 UTC (rev 4779) +++ labs/jbosslabs/trunk/portal-extensions/forge-tagme/src/java/org/jboss/labs/tagme/gwt/client/LabsDialogBox.java 2006-06-19 18:24:23 UTC (rev 4780) @@ -0,0 +1,14 @@ +package org.jboss.labs.tagme.gwt.client; + +import com.google.gwt.user.client.DOM; +import com.google.gwt.user.client.ui.DialogBox; + +public class LabsDialogBox extends DialogBox { + + public void setPopupPosition(int left, int top) { + DOM.setStyleAttribute(this.getElement(), "position", "absolute"); + DOM.setStyleAttribute(this.getElement(), "left", String.valueOf(left)+"px"); + DOM.setStyleAttribute(this.getElement(), "top", String.valueOf(top)+"px"); + } + +} Modified: labs/jbosslabs/trunk/portal-extensions/forge-tagme/src/java/org/jboss/labs/tagme/gwt/client/TagMe.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-tagme/src/java/org/jboss/labs/tagme/gwt/client/TagMe.java 2006-06-19 09:12:04 UTC (rev 4779) +++ labs/jbosslabs/trunk/portal-extensions/forge-tagme/src/java/org/jboss/labs/tagme/gwt/client/TagMe.java 2006-06-19 18:24:23 UTC (rev 4780) @@ -114,7 +114,7 @@ Image image = new Image("/file-access/default/theme/images/but_tagme.gif"); image.setStyleName("tagme_btn"); - image.addClickListener(new TagMeShowPopupListener(path, user, clas)); + image.addClickListener(new TagMeShowPopupListener(path, user, clas, image)); return image; //return new Button("TagMe", new TagMeShowPopupListener(path, user, clas)); Modified: labs/jbosslabs/trunk/portal-extensions/forge-tagme/src/java/org/jboss/labs/tagme/gwt/client/TagMeShowPopupListener.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-tagme/src/java/org/jboss/labs/tagme/gwt/client/TagMeShowPopupListener.java 2006-06-19 09:12:04 UTC (rev 4779) +++ labs/jbosslabs/trunk/portal-extensions/forge-tagme/src/java/org/jboss/labs/tagme/gwt/client/TagMeShowPopupListener.java 2006-06-19 18:24:23 UTC (rev 4780) @@ -25,6 +25,7 @@ import java.util.Vector; import com.google.gwt.core.client.GWT; +import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; @@ -61,13 +62,16 @@ private Button saveBtn; private FlexTable suggTable; + + private Vector suggestionCheckboxes; - private Vector suggestionCheckboxes; + private Image parentButton; - public TagMeShowPopupListener(String path, String user, String clas) { + public TagMeShowPopupListener(String path, String user, String clas, Image parentButton) { this.path = path; this.currentUser = user; this.clas = clas; + this.parentButton = parentButton; } public TagMeShowPopupListener getMyself() { @@ -76,7 +80,7 @@ public void refreshSugestions() { suggestionCheckboxes = new Vector(); - + while (suggTable.getRowCount() > 0) { table.removeRow(0); } @@ -89,12 +93,12 @@ AsyncCallback callback = new AsyncCallback() { public void onSuccess(Object result) { - Vector vect = (Vector)result; - - int rowLen = (int)Math.sqrt(vect.size()); - + Vector vect = (Vector) result; + + int rowLen = (int) Math.sqrt(vect.size()); + for (int i = 0; i < vect.size(); i++) { - CheckBox chBox = new CheckBox((String)vect.get(i)); + CheckBox chBox = new CheckBox((String) vect.get(i)); suggTable.setWidget(i / rowLen, i % rowLen, chBox); suggestionCheckboxes.add(chBox); } @@ -182,7 +186,7 @@ // call AJAX methos, after that callback is going to be executed tagging.getTags(path, clas, callback); - + // refresh tags also refreshSugestions(); } @@ -223,7 +227,7 @@ refreshTags(); - final DialogBox dialog = new DialogBox(); + final LabsDialogBox dialog = new LabsDialogBox(); HorizontalPanel btnPanel = new HorizontalPanel(); this.saveBtn = new Button("Save", new TagMeClickListener(path, @@ -256,8 +260,7 @@ dialog.setText("TagMe!"); - dialog.setPopupPosition(sender.getAbsoluteLeft(), sender - .getAbsoluteTop()); + dialog.setPopupPosition(DOM.getAbsoluteLeft(parentButton.getElement()), DOM.getAbsoluteTop(parentButton.getElement())); dialog.show(); Modified: labs/jbosslabs/trunk/portal-extensions/forge-theme/jbossForgeLayout.war/layouts/jbossForge.jsp =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-theme/jbossForgeLayout.war/layouts/jbossForge.jsp 2006-06-19 09:12:04 UTC (rev 4779) +++ labs/jbosslabs/trunk/portal-extensions/forge-theme/jbossForgeLayout.war/layouts/jbossForge.jsp 2006-06-19 18:24:23 UTC (rev 4780) @@ -125,8 +125,13 @@ <div id="jbfPageFooter"> <div id="Copyright"> - JBoss is a registered trademark and servicemark of JBoss Inc. 2002-2005 JBoss Inc. All rights reserved.<br /> -Theme made by <a href="http://mamut.net.pl">Szimano</a> + <a href="http://www.redhat.com"><img src="http://www.jboss.com/jbosstheme/img/logo_rh_home.png" alt=" Red Hat" width="96" height="31" border="0" /></a> + <br /> + <br /> + © 2002-2006 Red Hat, Inc. All rights reserved. JBoss is a registered trademark of Red Hat, Inc. + <a href="http://www.jboss.com/privacy_policy">Privacy Policy</a><br /> + + Theme made by <a href="http://mamut.net.pl">Szimano</a> </div> </div> |
From: <jbo...@li...> - 2006-06-19 09:12:08
|
Author: szimano Date: 2006-06-19 05:12:04 -0400 (Mon, 19 Jun 2006) New Revision: 4779 Added: labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/management/EMailNotifier.java Log: wiki MDB->SLSB Added: labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/management/EMailNotifier.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/management/EMailNotifier.java 2006-06-19 09:07:20 UTC (rev 4778) +++ labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/management/EMailNotifier.java 2006-06-19 09:12:04 UTC (rev 4779) @@ -0,0 +1,5 @@ +package org.jboss.wiki.management; + +public interface EMailNotifier { + public void sendNotification(NotificationMsg notifications); +} |
Author: szimano Date: 2006-06-19 05:07:20 -0400 (Mon, 19 Jun 2006) New Revision: 4778 Added: labs/jbosslabs/trunk/portal-extensions/configuration/to-copy/mail-service.xml labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-management/src/java/org/jboss/wiki/EMailNotifierSLSB.java Modified: labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/WikiCommon.java labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-management/src/java/org/jboss/wiki/MailNotificationBean.java Log: MDB->SLSB in wiki, mail configuration in repo Added: labs/jbosslabs/trunk/portal-extensions/configuration/to-copy/mail-service.xml =================================================================== --- labs/jbosslabs/trunk/portal-extensions/configuration/to-copy/mail-service.xml 2006-06-19 04:59:32 UTC (rev 4777) +++ labs/jbosslabs/trunk/portal-extensions/configuration/to-copy/mail-service.xml 2006-06-19 09:07:20 UTC (rev 4778) @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE server> +<!-- $Id: mail-service.xml,v 1.5.6.1 2005/06/01 06:20:43 starksm Exp $ --> + +<server> + + <!-- ==================================================================== --> + <!-- Mail Connection Factory --> + <!-- ==================================================================== --> + + <mbean code="org.jboss.mail.MailService" + name="jboss:service=Mail"> + <attribute name="JNDIName">java:/Mail</attribute> + <attribute name="User">nobody</attribute> + <attribute name="Password">password</attribute> + <attribute name="Configuration"> + <!-- Test --> + <configuration> + <!-- Change to your mail server prototocol --> + <property name="mail.store.protocol" value="pop3"/> + <property name="mail.transport.protocol" value="smtp"/> + + <!-- Change to the user who will receive mail --> + <property name="mail.user" value="nobody"/> + + <!-- Change to the mail server --> + <property name="mail.pop3.host" value="pop3.nosuchhost.nosuchdomain.com"/> + + <!-- Change to the SMTP gateway server --> + <property name="mail.smtp.host" value="localhost"/> + + <!-- Change to the address mail will be from --> + <property name="mail.from" value="do-...@jb..."/> + + <!-- Enable debugging output from the javamail classes --> + <property name="mail.debug" value="false"/> + </configuration> + <depends>jboss:service=Naming</depends> + </attribute> + </mbean> + +</server> 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-06-19 04:59:32 UTC (rev 4777) +++ labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/WikiCommon.java 2006-06-19 09:07:20 UTC (rev 4778) @@ -37,6 +37,7 @@ import org.jboss.mx.util.MBeanProxyExt; import org.jboss.mx.util.MBeanServerLocator; import org.jboss.wiki.exceptions.WikiManagementNotFoundException; +import org.jboss.wiki.management.EMailNotifier; import org.jboss.wiki.management.NotificationMsg; import org.jboss.wiki.management.WikiServiceMenagement; import org.jboss.wiki.plugins.DifferenceEngine; @@ -77,17 +78,20 @@ try { InitialContext context = new InitialContext(); - QueueSession sess = null; - Queue queue = null; + //QueueSession sess = null; + //Queue queue = null; + EMailNotifier notifer = null; try { - queue = (Queue) context.lookup("queue/wikiNotifications"); + /*queue = (Queue) context.lookup("queue/wikiNotifications"); QueueConnectionFactory factory = (QueueConnectionFactory) context .lookup("java:/ConnectionFactory"); sess = factory.createQueueConnection().createQueueSession( - false, QueueSession.AUTO_ACKNOWLEDGE); + false, QueueSession.AUTO_ACKNOWLEDGE);*/ - if (sess != null) { - + notifer = (EMailNotifier)context.lookup(EMailNotifier.class.getName()); + + //if (sess != null) { + if (notifer != null) { String notifs = page .getMetaDataProperty(WatchListPlugin.WATCH_PROPERTY); @@ -150,17 +154,18 @@ diffs + "<br /><hr />\n<br/>\nThis is notification of page: " + pageLink + "<br/>\n" + pageHtml.getContent(), page.getName(), fromEmail, pageLink); - ObjectMessage msg = sess.createObjectMessage(notifMsg); - sess.createSender(queue).send(msg); + //ObjectMessage msg = sess.createObjectMessage(notifMsg); + //sess.createSender(queue).send(msg); + notifer.sendNotification(notifMsg); } } else { log.error("Couldn't create queue session."); } } catch (CloneNotSupportedException e) { log.error(e); - } catch (JMSException e) { + }/* catch (JMSException e) { log.error(e); - } + }*/ } catch (NamingException e1) { log.error(e1); } Added: labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-management/src/java/org/jboss/wiki/EMailNotifierSLSB.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-management/src/java/org/jboss/wiki/EMailNotifierSLSB.java 2006-06-19 04:59:32 UTC (rev 4777) +++ labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-management/src/java/org/jboss/wiki/EMailNotifierSLSB.java 2006-06-19 09:07:20 UTC (rev 4778) @@ -0,0 +1,78 @@ +package org.jboss.wiki; + +import java.util.Date; + +import javax.ejb.Stateless; +import javax.mail.Address; +import javax.mail.MessagingException; +import javax.mail.Session; +import javax.mail.Transport; +import javax.mail.Message.RecipientType; +import javax.mail.internet.AddressException; +import javax.mail.internet.InternetAddress; +import javax.mail.internet.MimeMessage; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import javax.rmi.PortableRemoteObject; + +import org.jboss.logging.Logger; +import org.jboss.wiki.management.EMailNotifier; +import org.jboss.wiki.management.NotificationMsg; + +@Stateless +public class EMailNotifierSLSB implements EMailNotifier { + + private static final Logger log = Logger.getLogger(EMailNotifier.class); + + public synchronized void sendNotification(NotificationMsg notifications) { + + try { + Session session = (Session) PortableRemoteObject.narrow( + new InitialContext().lookup("java:Mail"), Session.class); + + log.debug("Got email notification msg"); + + for (String email : notifications.getEmails()) { + log.debug("MDB for: " + email); + + StringBuffer buffer = null; + Address[] to = null; + MimeMessage m = new MimeMessage(session); + + if (email != null) { + m + .setFrom(new InternetAddress(notifications + .getFromEmail())); + 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 ") + .append(notifications.getPageLink()).append( + "<br />\n"); + buffer.append(notifications.getPageContent()); + + m.setContent(buffer.toString(), + "text/html; charset=\"UTF-8\""); + Transport.send(m); + log.debug("Notification send to: "+email); + } + } + } catch (ClassCastException e) { + log.error(e); + } catch (NamingException e) { + log.error(e); + } catch (AddressException e) { + log.error(e); + } catch (MessagingException e) { + log.error(e); + } + } + +} Modified: 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-06-19 04:59:32 UTC (rev 4777) +++ labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-management/src/java/org/jboss/wiki/MailNotificationBean.java 2006-06-19 09:07:20 UTC (rev 4778) @@ -19,7 +19,7 @@ * 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; +/*package org.jboss.wiki; import java.util.Date; @@ -102,4 +102,4 @@ } } -} +}*/ |
From: <jbo...@li...> - 2006-06-19 04:59:39
|
Author: mic...@jb... Date: 2006-06-19 00:59:32 -0400 (Mon, 19 Jun 2006) New Revision: 4777 Modified: labs/jbossrules/trunk/documentation/training/developers-course/Module 3 - Rule Engine Concepts 1.odp Log: finished, finally. That took ages. Modified: labs/jbossrules/trunk/documentation/training/developers-course/Module 3 - Rule Engine Concepts 1.odp =================================================================== (Binary files differ) |
From: <jbo...@li...> - 2006-06-18 23:41:22
|
Author: mic...@jb... Date: 2006-06-18 19:41:14 -0400 (Sun, 18 Jun 2006) New Revision: 4776 Modified: labs/jbossrules/trunk/documentation/training/developers-course/Module 3 - Rule Engine Concepts 1.odp Log: update Modified: labs/jbossrules/trunk/documentation/training/developers-course/Module 3 - Rule Engine Concepts 1.odp =================================================================== (Binary files differ) |
From: <jbo...@li...> - 2006-06-18 16:41:29
|
Author: unibrew Date: 2006-06-18 12:41:26 -0400 (Sun, 18 Jun 2006) New Revision: 4775 Modified: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDB.java Log: Replacing MDB executions with SSB. 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-06-16 13:51:01 UTC (rev 4774) +++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDB.java 2006-06-18 16:41:26 UTC (rev 4775) @@ -123,32 +123,36 @@ downloadCounters.get(link).increment(); try { - //CountersServiceInterface countersService = - // (CountersServiceInterface) ctx.lookup(CountersServiceInterface.jndiName); - //countersService.incrementCounter(link); + CountersServiceInterface countersService = + (CountersServiceInterface) ctx.lookup(CountersServiceInterface.jndiName); + countersService.incrementCounter(link); + // MDB CODE COMMENTED OUT BECAUSE OF MDB ISSUES // 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"); - QueueConnectionFactory factory = - (QueueConnectionFactory) ctx.lookup("java:/ConnectionFactory"); - sess =factory.createQueueConnection().createQueueSession(false, - QueueSession.AUTO_ACKNOWLEDGE); - if (sess != null) - { - TextMessage msg = sess.createTextMessage(link); - sess.createSender(queue).send(msg); - } + //QueueSession sess = null; + //Queue queue = null; + //queue = (Queue) ctx.lookup("queue/jblab_counters"); + //QueueConnectionFactory factory = + // (QueueConnectionFactory) ctx.lookup("java:/ConnectionFactory"); + //sess =factory.createQueueConnection().createQueueSession(false, + // QueueSession.AUTO_ACKNOWLEDGE); + //if (sess != null) + //{ + // TextMessage msg = sess.createTextMessage(link); + // sess.createSender(queue).send(msg); + //} } catch (NamingException e) { getLogger().error("CountersService was not found while incrementing counter.",e); } - catch (JMSException e) - { - getLogger().error("Problem while using JMS to send increment command to MDB.",e); + //catch (JMSException e) + //{ + // getLogger().error("Problem while using JMS to send increment command to MDB.",e); + //} + catch (Exception e) { + getLogger().error("CountersService problem while incrementing counter.",e); } } } |
From: <jbo...@li...> - 2006-06-16 13:51:05
|
Author: mar...@jb... Date: 2006-06-16 09:51:01 -0400 (Fri, 16 Jun 2006) New Revision: 4774 Added: labs/jbossesb/branches/Alpha1/ Log: Frozen development on Alpha1 in favour of Rosetta ESB. This branch is in case existing changes against Alpha1 are outstanding. Copied: labs/jbossesb/branches/Alpha1 (from rev 4773, labs/jbossesb/trunk) |
From: <jbo...@li...> - 2006-06-16 13:48:27
|
Author: mar...@jb... Date: 2006-06-16 09:48:23 -0400 (Fri, 16 Jun 2006) New Revision: 4773 Added: labs/jbossesb/tags/Alpha1/ Log: Frozen development of Alpha1 in favour of Rosetta ESB code. Copied: labs/jbossesb/tags/Alpha1 (from rev 4772, labs/jbossesb/trunk) |