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...> - 2005-12-19 08:46:35
|
Author: adamw Date: 2005-12-19 03:46:31 -0500 (Mon, 19 Dec 2005) New Revision: 1857 Modified: trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/service/ResourceWatcher.java Log: http://jira.jboss.com/jira/browse/JBLAB-576 - fixed Modified: trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/service/ResourceWatcher.java =================================================================== --- trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/service/ResourceWatcher.java 2005-12-19 00:20:03 UTC (rev 1856) +++ trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/service/ResourceWatcher.java 2005-12-19 08:46:31 UTC (rev 1857) @@ -50,7 +50,7 @@ try { lastUpdates.put(name, cm.getNode(name).getLastModification()); } catch (ResourceDoesNotExist e) { - // Just not adding. + lastUpdates.put(name, new Long(-1)); } } @@ -66,8 +66,7 @@ try { lastModification = cm.getNode(name).getLastModification(); } catch (ResourceDoesNotExist e) { - // Not checking. - continue; + lastModification = -1; } if (lastModification != lastUpdates.get(name)) { |
From: <jbo...@li...> - 2005-12-19 00:20:08
|
Author: mar...@jb... Date: 2005-12-18 19:20:03 -0500 (Sun, 18 Dec 2005) New Revision: 1856 Modified: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/AlphaNode.java trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/Rete.java trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/RuleBaseImpl.java Log: JBRULES-10 : Rete Builder -Take a given AND Conditional Element and turn it and all its children into a Rete network. Modified: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/AlphaNode.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/AlphaNode.java 2005-12-19 00:07:09 UTC (rev 1855) +++ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/AlphaNode.java 2005-12-19 00:20:03 UTC (rev 1856) @@ -113,5 +113,11 @@ AlphaNode other = (AlphaNode) object; return this.objectSource.equals( other.objectSource ) && this.constraint.equals( other.constraint ); + } + + public void remove() + { + // TODO Auto-generated method stub + } } Modified: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/Rete.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/Rete.java 2005-12-19 00:07:09 UTC (rev 1855) +++ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/Rete.java 2005-12-19 00:20:03 UTC (rev 1856) @@ -50,6 +50,7 @@ import org.drools.FactException; import org.drools.rule.And; +import org.drools.rule.InvalidPatternException; import org.drools.rule.Rule; import org.drools.spi.ObjectType; import org.drools.spi.PropagationContext; @@ -218,7 +219,7 @@ // do nothing this is the root node } - void addRule(Rule rule) + void addRule(Rule rule) throws InvalidPatternException { //And is the implicit head node And[] rules = rule.getProcessPatterns(); @@ -251,5 +252,11 @@ it.remove(); } } + + public void remove() + { + // TODO Auto-generated method stub + + } } Modified: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/RuleBaseImpl.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/RuleBaseImpl.java 2005-12-19 00:07:09 UTC (rev 1855) +++ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/RuleBaseImpl.java 2005-12-19 00:20:03 UTC (rev 1856) @@ -54,6 +54,7 @@ import org.drools.RuleSetIntegrationException; import org.drools.WorkingMemory; import org.drools.conflict.DefaultConflictResolver; +import org.drools.rule.InvalidPatternException; import org.drools.rule.Rule; import org.drools.rule.RuleSet; import org.drools.spi.ConflictResolver; @@ -272,9 +273,10 @@ * if an error prevents complete construction of the network for * the <code>Rule</code>. * @throws FactException + * @throws InvalidPatternException */ public void addRuleSet(RuleSet ruleSet) throws RuleIntegrationException, - RuleSetIntegrationException, FactException + RuleSetIntegrationException, FactException, InvalidPatternException { Map newApplicationData = ruleSet.getApplicationData( ); @@ -301,7 +303,7 @@ } } - public void addRule(Rule rule) throws FactException, RuleIntegrationException + public void addRule(Rule rule) throws FactException, RuleIntegrationException, InvalidPatternException { this.builder.addRule( rule ); |
From: <jbo...@li...> - 2005-12-19 00:07:13
|
Author: mar...@jb... Date: 2005-12-18 19:07:09 -0500 (Sun, 18 Dec 2005) New Revision: 1855 Added: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/RightInputAdapterNode.java trunk/labs/jbossrules/drools-core/src/main/java/org/drools/rule/InvalidPatternException.java Log: JBRULES-10 : Rete Builder -Take a given AND Conditional Element and turn it and all its children into a Rete network. Added: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/RightInputAdapterNode.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/RightInputAdapterNode.java 2005-12-19 00:06:15 UTC (rev 1854) +++ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/RightInputAdapterNode.java 2005-12-19 00:07:09 UTC (rev 1855) @@ -0,0 +1,60 @@ +package org.drools.reteoo; + +import org.drools.FactException; +import org.drools.FactHandle; +import org.drools.spi.PropagationContext; + +public class RightInputAdapterNode extends ObjectSource + implements + TupleSink +{ + private final TupleSource tupleSource; + + private final int column; + + public RightInputAdapterNode(int id, + int column, + TupleSource source) + { + + super( id ); + this.column = column; + this.tupleSource = source; + } + + public void assertTuple(ReteTuple tuple, + PropagationContext context, + WorkingMemoryImpl workingMemory) throws FactException + { + Object object = ( Object ) tuple.get( this.column ); + FactHandleImpl handle = ( FactHandleImpl ) tuple.getKey().get( this.column ); + + propagateAssertObject(object, handle, context, workingMemory) ; + } + + public void retractTuples(TupleKey key, + PropagationContext context, + WorkingMemoryImpl workingMemory) throws FactException + { + FactHandleImpl handle = ( FactHandleImpl ) key.get( this.column ); + + propagateRetractObject(handle, context, workingMemory); + } + + public void attach() + { + this.tupleSource.addTupleSink( this ); + } + + public int getId() + { + return id; + } + + public void remove() + { + // TODO Auto-generated method stub + + } + +} Added: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/rule/InvalidPatternException.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/main/java/org/drools/rule/InvalidPatternException.java 2005-12-19 00:06:15 UTC (rev 1854) +++ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/rule/InvalidPatternException.java 2005-12-19 00:07:09 UTC (rev 1855) @@ -0,0 +1,35 @@ +package org.drools.rule; + +public class InvalidPatternException extends RuleConstructionException { + /** + * @see java.lang.Exception#Exception() + */ + InvalidPatternException() + { + super(); + } + + /** + * @see java.lang.Exception#Exception(String message) + */ + InvalidPatternException( String message ) + { + super( message ); + } + + /** + * @see java.lang.Exception#Exception(String message, Throwable cause) + */ + InvalidPatternException( String message, Throwable cause ) + { + super( message, cause ); + } + + /** + * @see java.lang.Exception#Exception(Throwable cause) + */ + InvalidPatternException( Throwable cause ) + { + super( cause ); + } +} |
Author: mar...@jb... Date: 2005-12-18 19:06:15 -0500 (Sun, 18 Dec 2005) New Revision: 1854 Added: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/rule/Exists.java trunk/labs/jbossrules/drools-core/src/main/java/org/drools/rule/PredicateConstraint.java trunk/labs/jbossrules/drools-core/src/main/java/org/drools/spi/PredicateExpressionConstraint.java Removed: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/rule/BooleanConstraint.java trunk/labs/jbossrules/drools-core/src/main/java/org/drools/rule/Exist.java trunk/labs/jbossrules/drools-core/src/main/java/org/drools/spi/BooleanExpressionConstraint.java Modified: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/NoSuchFactObjectException.java trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/AlphaNode.java trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/BetaNode.java trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/BetaNodeBinder.java trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/Builder.java trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/ObjectSource.java trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/ObjectTypeNode.java trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/Rete.java trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/ReteTuple.java trunk/labs/jbossrules/drools-core/src/main/java/org/drools/rule/Column.java trunk/labs/jbossrules/drools-core/src/main/java/org/drools/rule/LogicTransformer.java trunk/labs/jbossrules/drools-core/src/main/java/org/drools/spi/ClassObjectType.java trunk/labs/jbossrules/drools-core/src/main/java/org/drools/spi/Tuple.java trunk/labs/jbossrules/drools-core/src/test/java/org/drools/reteoo/JoinNodeTest.java trunk/labs/jbossrules/drools-core/src/test/java/org/drools/reteoo/NotNodeTest.java trunk/labs/jbossrules/drools-core/src/test/java/org/drools/rule/ConstraintTest.java trunk/labs/jbossrules/drools-core/src/test/java/org/drools/rule/LogicTransformerTest.java Log: JBRULES-10 : Rete Builder -Take a given AND Conditional Element and turn it and all its children into a Rete network. Modified: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/NoSuchFactObjectException.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/main/java/org/drools/NoSuchFactObjectException.java 2005-12-18 23:11:49 UTC (rev 1853) +++ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/NoSuchFactObjectException.java 2005-12-19 00:06:15 UTC (rev 1854) @@ -55,7 +55,7 @@ * @version $Id: NoSuchFactObjectException.java,v 1.3 2003/11/19 21:31:09 bob * Exp $ */ -public class NoSuchFactObjectException extends FactException +public class NoSuchFactObjectException extends RuntimeException { /** Invalid fact handle. */ private final FactHandle handle; Modified: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/AlphaNode.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/AlphaNode.java 2005-12-18 23:11:49 UTC (rev 1853) +++ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/AlphaNode.java 2005-12-19 00:06:15 UTC (rev 1854) @@ -97,4 +97,21 @@ { return new HashSet( ); } + + public boolean equals( Object object ) + { + if ( this == object ) + { + return true; + } + + if ( object == null || getClass( ) != object.getClass( ) ) + { + return false; + } + + AlphaNode other = (AlphaNode) object; + + return this.objectSource.equals( other.objectSource ) && this.constraint.equals( other.constraint ); + } } Modified: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/BetaNode.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/BetaNode.java 2005-12-18 23:11:49 UTC (rev 1853) +++ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/BetaNode.java 2005-12-19 00:06:15 UTC (rev 1854) @@ -220,7 +220,7 @@ BetaNode other = (BetaNode) object; - return this.leftInput.equals( other.leftInput ) && this.rightInput.equals( other.rightInput ); + return this.leftInput.equals( other.leftInput ) && this.rightInput.equals( other.rightInput ) && this.joinNodeBinder.equals( other.joinNodeBinder ) ; } public Object createMemory() Modified: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/BetaNodeBinder.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/BetaNodeBinder.java 2005-12-18 23:11:49 UTC (rev 1853) +++ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/BetaNodeBinder.java 2005-12-19 00:06:15 UTC (rev 1854) @@ -1,66 +1,119 @@ package org.drools.reteoo; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + import org.drools.FactHandle; import org.drools.NoSuchFactObjectException; import org.drools.WorkingMemory; +import org.drools.spi.ClassObjectType; import org.drools.spi.Constraint; import org.drools.spi.Tuple; public class BetaNodeBinder { - private final Constraint constraint; + private final Constraint[] constraints; public BetaNodeBinder( ) { - this.constraint = null; + this.constraints = null; } public BetaNodeBinder( Constraint constraint ) { - this.constraint = constraint; + this.constraints = new Constraint[] { constraint }; } + public BetaNodeBinder( Constraint[] constraints ) + { + this.constraints = constraints; + } + boolean isAllowed(Object object, FactHandle handle, Tuple tuple, WorkingMemory workingMemory) { - if ( constraint == null ) + if ( constraints == null ) { return true; } - return this.constraint.isAllowed( object, - handle, - tuple ); + for (int i=0; i < this.constraints.length; i++) + { + if ( ! this.constraints[i].isAllowed( object, + handle, + tuple ) ) + { + return false; + } + } + return true; + } boolean isAllowed(FactHandle handle, Tuple tuple, WorkingMemory workingMemory) { - if ( constraint == null ) + Object object = workingMemory.getObject( handle ); + + return isAllowed(object, handle, tuple, workingMemory); + } + + public Set getRequiredDeclarations() + { + Set declarations = new HashSet(); + for ( int i = 0; i < this.constraints.length; i++ ) { + Collections.addAll(declarations, this.constraints[i].getRequiredDeclarations()); + } + return declarations; + } + + public int hashCode() + { + return this.constraints.hashCode(); + } + + /** + * Determine if another object is equal to this. + * + * @param object The object to test. + * + * @return <code>true</code> if <code>object</code> is equal to this, + * otherwise <code>false</code>. + */ + public boolean equals( Object object ) + { + if ( this == object ) + { return true; } - - boolean isAllowed = false; - try + if ( object == null || getClass( ) != object.getClass( ) ) { - isAllowed = isAllowed( workingMemory.getObject( handle ), - handle, - tuple, - workingMemory ); + return false; } - catch ( NoSuchFactObjectException e ) + + BetaNodeBinder other = ( BetaNodeBinder ) object; + + if ( this.constraints.length != other.constraints.length ) { - //do nothing, as we return false. - //also this should never happen + return false; } - - return isAllowed; - } + for (int i=0; i < this.constraints.length; i++) + { + if ( ! this.constraints[i].equals( other.constraints[i] ) ) + { + return false; + } + } + + return true; + } + } Modified: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/Builder.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/Builder.java 2005-12-18 23:11:49 UTC (rev 1853) +++ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/Builder.java 2005-12-19 00:06:15 UTC (rev 1854) @@ -43,6 +43,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -55,8 +56,13 @@ import org.drools.RuleSetIntegrationException; import org.drools.conflict.DefaultConflictResolver; import org.drools.rule.And; +import org.drools.rule.Binding; import org.drools.rule.Column; +import org.drools.rule.ConditionalElement; import org.drools.rule.Declaration; +import org.drools.rule.Exists; +import org.drools.rule.InvalidPatternException; +import org.drools.rule.LiteralConstraint; import org.drools.rule.Not; import org.drools.rule.Rule; import org.drools.rule.RuleSet; @@ -84,16 +90,24 @@ // ------------------------------------------------------------ /** Rete network to build against. */ - private Rete rete; + private Rete rete; /** Rule-sets added. */ - private List ruleSets; + private List ruleSets; /** Nodes that have been attached. */ - private Map attachedNodes; + private Map attachedNodes; - private Map applicationData; - + private Map applicationData; + + private TupleSource tupleSource; + + private ObjectSource objectSource; + + private Map declarations; + + private int id; + // ------------------------------------------------------------ // Constructors // ------------------------------------------------------------ @@ -107,12 +121,10 @@ this.rete = new Rete( ); this.ruleSets = new ArrayList( ); this.attachedNodes = new HashMap( ); - this.applicationData = new HashMap( ); + this.applicationData = new HashMap( ); + this.declarations = new HashMap( ); + } - - this.rete.getOrCreateObjectTypeNode( new ClassObjectType( InitialFact.class ) ); - } - // ------------------------------------------------------------ // Instance methods // ------------------------------------------------------------ @@ -126,58 +138,307 @@ * @throws RuleIntegrationException * if an error prevents complete construction of the network for * the <code>Rule</code>. + * @throws InvalidPatternException */ - void addRule(Rule rule) throws RuleIntegrationException - { - And[] and = rule.getProcessPatterns(); + void addRule(Rule rule) throws InvalidPatternException + { + And[] and = rule.getProcessPatterns( ); for ( int i = 0; i < and.length; i++ ) { - addRule( and[i], rule ); + addRule( and[i], + rule ); } } - - private void addRule( And and, Rule rule ) + + private void addRule(And and, + Rule rule) { - for(Iterator it = and.getChildren().iterator(); it.hasNext(); ) + for ( Iterator it = and.getChildren( ).iterator( ); it.hasNext( ); ) { - Object object = it.next(); - + Object object = it.next( ); + + BetaNodeBinder binder; + Column column; + + if ( object instanceof Column ) + { + column = (Column) object; + + binder = attachColumn( (Column) object, + and ); + + // If a tupleSource does not exist then we need to adapt this into + // a TupleSource using LeftInputAdapterNode + if ( this.tupleSource == null ) + { + this.tupleSource = attachNode( new LeftInputAdapterNode( this.id++, + column.getIndex( ), + this.objectSource ) ); + + // objectSource is created by the attachColumn method, if we adapt this to + // a TupleSource then we need to null the objectSource reference. + this.objectSource = null; + } + } + else + { + // If its not a Column then it can either be a Not or an Exists + ConditionalElement ce = (ConditionalElement) object; + while ( !(ce.getChildren( ).get( 0 ) instanceof Column) ) + { + ce = (ConditionalElement) ce.getChildren( ).get( 0 ); + } + column = (Column) ce.getChildren( ).get( 0 ); + binder = attachColumn( (Column) object, + and ); + + // If a tupleSource does not exist then we need to adapt an + // InitialFact into a a TupleSource using LeftInputAdapterNode + if ( this.tupleSource == null ) + { + ObjectSource objectSource = attachNode( new ObjectTypeNode( this.id++, + new ClassObjectType( InitialFact.class ), + this.rete ) ); + + this.tupleSource = attachNode( new LeftInputAdapterNode( this.id++, + column.getIndex( ), + objectSource ) ); + + } + } + + if ( object instanceof Not ) { - Not not = (Not) object; - Object child = not.getChild(); - - if ( child instanceof Column) - { - - Column column = (Column) child; - if ( !hasDependencies(column.getConstraints() ) ) - { - - } - - } - new NotNode(); + attachNot( this.tupleSource, + (Not) object, + this.objectSource, + binder, + column ); } + else if ( object instanceof Exists ) + { + attachExists( this.tupleSource, + (Exists) object, + this.objectSource, + binder, + column ); + } + else if ( this.objectSource != null ) + { + this.tupleSource = attachNode( new JoinNode( this.id++, + this.tupleSource, + this.objectSource, + column.getIndex( ), + binder ) ); + } } } - - - private boolean hasDependencies(List constraints) + + private BetaNodeBinder attachColumn(Column column, + ConditionalElement parent) { - boolean hasDependencies = false; - for (Iterator it = constraints.iterator(); it.hasNext(); ) + addDeclarations( column ); + + List predicates = attachAlphaNodes( column ); + + BetaNodeBinder binder; + + if ( !predicates.isEmpty( ) ) { - Constraint constraint = (Constraint)it.next(); - if (constraint.getRequiredDeclarations().length > 0) + binder = new BetaNodeBinder( (Constraint[]) predicates.toArray( new Constraint[predicates.size( )] ) ); + } + else + { + binder = new BetaNodeBinder( ); + } + + return binder; + } + + private void addDeclarations(Column column) + { + for ( Iterator it = column.getDeclarations( ).iterator( ); it.hasNext( ); ) + { + Declaration declaration = (Declaration) it.next( ); + this.declarations.put( declaration.getIdentifier( ), + declaration ); + } + + if ( column.getBinding( ) != null ) + { + Binding binding = column.getBinding( ); + this.declarations.put( binding.getIdentifier( ), + binding ); + } + } + + public List attachAlphaNodes(Column column) + { + List constraints = column.getConstraints( ); + + ObjectSource objectSource = attachNode( new ObjectTypeNode( this.id++, + column.getObjectType( ), + this.rete ) ); + + List predicateConstraints = new ArrayList( ); + + for ( Iterator it = constraints.iterator( ); it.hasNext( ); ) + { + Constraint constraint = (Constraint) it.next( ); + if ( constraint instanceof LiteralConstraint ) { - return true; + this.objectSource = attachNode( new AlphaNode( this.id++, + constraint, + true, + objectSource ) ); } - } - return false; + else + { + predicateConstraints.add( constraint ); + } + } + + return predicateConstraints; } + private void attachNot(TupleSource tupleSource, + Not not, + ObjectSource ObjectSource, + BetaNodeBinder binder, + Column column) + { + NotNode notNode = (NotNode) attachNode( new NotNode( this.id++, + tupleSource, + ObjectSource, + column.getIndex( ), + binder ) ); + if ( not.getChild( ) instanceof Not ) + { - + RightInputAdapterNode adapter = (RightInputAdapterNode) attachNode( new RightInputAdapterNode( this.id++, + column.getIndex( ), + notNode ) ); + attachNot( tupleSource, + (Not) not.getChild( ), + adapter, + new BetaNodeBinder( ), + column ); + } + else if ( not.getChild( ) instanceof Exists ) + { + RightInputAdapterNode adapter = (RightInputAdapterNode) attachNode( new RightInputAdapterNode( this.id++, + column.getIndex( ), + notNode ) ); + attachExists( tupleSource, + (Exists) not.getChild( ), + adapter, + new BetaNodeBinder( ), + column ); + } + else + { + this.tupleSource = notNode; + } + } + private void attachExists(TupleSource tupleSource, + Exists exists, + ObjectSource ObjectSource, + BetaNodeBinder binder, + Column column) + { + NotNode notNode = (NotNode) attachNode( new NotNode( this.id++, + tupleSource, + ObjectSource, + column.getIndex( ), + binder ) ); + RightInputAdapterNode adapter = (RightInputAdapterNode) attachNode( new RightInputAdapterNode( this.id++, + column.getIndex( ), + notNode ) ); + notNode = (NotNode) attachNode( new NotNode( this.id++, + tupleSource, + adapter, + column.getIndex( ), + new BetaNodeBinder( ) ) ); + + if ( exists.getChild( ) instanceof Not ) + { + adapter = (RightInputAdapterNode) attachNode( new RightInputAdapterNode( this.id++, + column.getIndex( ), + notNode ) ); + attachNot( tupleSource, + (Not) exists.getChild( ), + adapter, + new BetaNodeBinder( ), + column ); + } + else if ( exists.getChild( ) instanceof Exists ) + { + adapter = (RightInputAdapterNode) attachNode( new RightInputAdapterNode( this.id++, + column.getIndex( ), + notNode ) ); + attachExists( tupleSource, + (Exists) exists.getChild( ), + adapter, + new BetaNodeBinder( ), + column ); + } + else + { + this.tupleSource = notNode; + } + } + + /** + * Attaches a node into the network. If a node already exists that could + * substitute, it is used instead. + * + * @param candidate + * The node to attach. + * @param leafNodes + * The list to which the newly added node will be added. + */ + private TupleSource attachNode(TupleSource candidate) + { + TupleSource node = (TupleSource) this.attachedNodes.get( candidate ); + + if ( node == null ) + { + candidate.attach( ); + + this.attachedNodes.put( candidate, + candidate ); + + node = candidate; + } + else + { + id--; + } + + return node; + } + + private ObjectSource attachNode(ObjectSource candidate) + { + ObjectSource node = (ObjectSource) this.attachedNodes.get( candidate ); + + if ( node == null ) + { + candidate.attach( ); + + this.attachedNodes.put( candidate, + candidate ); + + node = candidate; + } + else + { + id--; + } + + return node; + } + } Modified: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/ObjectSource.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/ObjectSource.java 2005-12-18 23:11:49 UTC (rev 1853) +++ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/ObjectSource.java 2005-12-19 00:06:15 UTC (rev 1854) @@ -221,4 +221,11 @@ public abstract void remove(); + public int hashCode() + { + return this.id; + } + + + } Modified: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/ObjectTypeNode.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/ObjectTypeNode.java 2005-12-18 23:11:49 UTC (rev 1853) +++ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/ObjectTypeNode.java 2005-12-19 00:06:15 UTC (rev 1854) @@ -237,6 +237,20 @@ { return new PrimitiveLongMap( 32, 8 ); + } + + public boolean equals( Object object ) + { + if ( this == object ) + { + return true; + } + + if ( object == null || getClass( ) != object.getClass( ) ) + { + return false; + } + + return this.objectType.equals( ( ( ObjectTypeNode ) object).getObjectType() ); } - } Modified: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/Rete.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/Rete.java 2005-12-18 23:11:49 UTC (rev 1853) +++ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/Rete.java 2005-12-19 00:06:15 UTC (rev 1854) @@ -50,7 +50,6 @@ import org.drools.FactException; import org.drools.rule.And; -import org.drools.rule.LogicTransformer; import org.drools.rule.Rule; import org.drools.spi.ObjectType; import org.drools.spi.PropagationContext; @@ -188,33 +187,7 @@ return (ObjectTypeNode) this.objectTypeNodes.get( objectType ); } - /** - * Retrieve an <code>ObjectTypeNode</code> keyed by - * <code>ObjectType</code>, creating one, if necessary. - * - * @param objectType - * The <code>ObjectType</code> key. - * - * @return The matching <code>ObjectTypeNode</codeb>. - */ - ObjectTypeNode getOrCreateObjectTypeNode(ObjectType objectType) - { - ObjectTypeNode node = getObjectTypeNode( objectType ); - if ( node == null ) - { - node = new ObjectTypeNode( 0, - objectType, - this ); - - node.attach( ); - } - - this.rulesToUpdate.add( node ); - - return node; - } - /** * Add an <code>ObjectTypeNode</code> child to this <code>Rete</code>. * Modified: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/ReteTuple.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/ReteTuple.java 2005-12-18 23:11:49 UTC (rev 1853) +++ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/reteoo/ReteTuple.java 2005-12-19 00:06:15 UTC (rev 1854) @@ -159,7 +159,7 @@ public Object get(Declaration declaration) { return declaration.getValue( get( declaration.getColumn( ) ) ); - } + } /** * @see Tuple Deleted: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/rule/BooleanConstraint.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/main/java/org/drools/rule/BooleanConstraint.java 2005-12-18 23:11:49 UTC (rev 1853) +++ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/rule/BooleanConstraint.java 2005-12-19 00:06:15 UTC (rev 1854) @@ -1,70 +0,0 @@ -package org.drools.rule; - -import org.drools.FactHandle; -import org.drools.spi.BooleanExpressionConstraint; -import org.drools.spi.Constraint; -import org.drools.spi.Tuple; - -public class BooleanConstraint - implements - Constraint -{ - private final Declaration declaration; - - private final BooleanExpressionConstraint booleanExpression; - - private final Declaration[] requiredDeclarations; - - public BooleanConstraint(BooleanExpressionConstraint expression, - Declaration declaration) - { - this( expression, - declaration, - null ); - } - - public BooleanConstraint(BooleanExpressionConstraint expression, - Declaration declaration, - Declaration[] declarations) - { - this.booleanExpression = expression; - - this.declaration = declaration; - - if ( declarations == null ) - { - this.requiredDeclarations = new Declaration[]{}; - } - else - { - this.requiredDeclarations = declarations; - } - } - - public BooleanExpressionConstraint getExpression() - { - return this.booleanExpression; - } - - public Declaration[] getRequiredDeclarations() - { - return requiredDeclarations; - } - - public Declaration getDeclaration() - { - return this.declaration; - } - - public boolean isAllowed(Object object, - FactHandle handle, - Tuple tuple) - { - return this.booleanExpression.isAllowed( object, - handle, - this.declaration, - this.requiredDeclarations, - tuple ); - } - -}; Modified: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/rule/Column.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/main/java/org/drools/rule/Column.java 2005-12-18 23:11:49 UTC (rev 1853) +++ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/rule/Column.java 2005-12-19 00:06:15 UTC (rev 1854) @@ -10,6 +10,7 @@ { private final ObjectType objectType; private List constraints = Collections.EMPTY_LIST; + private List declarations = Collections.EMPTY_LIST; private final ColumnBinding binding; private final int index; @@ -24,6 +25,7 @@ public Column(int index, ObjectType objectType, ColumnBinding binding) + { this.index = index; this.objectType = objectType; @@ -34,7 +36,21 @@ { return this.objectType; } + + public List getDeclarations() + { + return Collections.unmodifiableList( this.declarations ); + } + public void addDeclaration(Declaration declaration) + { + if (this.declarations == Collections.EMPTY_LIST) + { + this.declarations = new ArrayList( 1 ); + } + this.declarations.add( declaration ); + } + public List getConstraints() { return Collections.unmodifiableList( this.constraints ); Deleted: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/rule/Exist.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/main/java/org/drools/rule/Exist.java 2005-12-18 23:11:49 UTC (rev 1853) +++ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/rule/Exist.java 2005-12-19 00:06:15 UTC (rev 1854) @@ -1,12 +0,0 @@ -package org.drools.rule; - -import java.util.ArrayList; -import java.util.List; - -public class Exist extends ConditionalElement -{ - public Object getChild() - { - return getChildren().get( 0 ); - } -} Copied: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/rule/Exists.java (from rev 1776, trunk/labs/jbossrules/drools-core/src/main/java/org/drools/rule/Exist.java) =================================================================== --- trunk/labs/jbossrules/drools-core/src/main/java/org/drools/rule/Exist.java 2005-12-10 17:37:55 UTC (rev 1776) +++ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/rule/Exists.java 2005-12-19 00:06:15 UTC (rev 1854) @@ -0,0 +1,12 @@ +package org.drools.rule; + +import java.util.ArrayList; +import java.util.List; + +public class Exists extends ConditionalElement +{ + public Object getChild() + { + return getChildren().get( 0 ); + } +} Modified: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/rule/LogicTransformer.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/main/java/org/drools/rule/LogicTransformer.java 2005-12-18 23:11:49 UTC (rev 1853) +++ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/rule/LogicTransformer.java 2005-12-19 00:06:15 UTC (rev 1854) @@ -55,14 +55,14 @@ And.class ); addTransformationPair( Or.class, Or.class ); - addTransformationPair( Exist.class, - Exist.class ); + addTransformationPair( Exists.class, + Exists.class ); // these pairs will be transformed addTransformationPair( Not.class, Or.class, new NotOrTransformation( ) ); - addTransformationPair( Exist.class, + addTransformationPair( Exists.class, Or.class, new ExistOrTransformation( ) ); addTransformationPair( And.class, @@ -401,9 +401,9 @@ /** * This data structure is not valid - * (Exist (OR (A B) + * (Exists (OR (A B) * <pre> - * Exist + * Exists * | * or * / \ @@ -418,7 +418,7 @@ public ConditionalElement transform(ConditionalElement exist) throws InvalidPatternException { - throw new InvalidPatternException("You cannot nest an OR within an Exist"); + throw new InvalidPatternException("You cannot nest an OR within an Exists"); } } Copied: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/rule/PredicateConstraint.java (from rev 1776, trunk/labs/jbossrules/drools-core/src/main/java/org/drools/rule/BooleanConstraint.java) =================================================================== --- trunk/labs/jbossrules/drools-core/src/main/java/org/drools/rule/BooleanConstraint.java 2005-12-10 17:37:55 UTC (rev 1776) +++ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/rule/PredicateConstraint.java 2005-12-19 00:06:15 UTC (rev 1854) @@ -0,0 +1,72 @@ +package org.drools.rule; + +import org.drools.FactHandle; +import org.drools.spi.PredicateExpressionConstraint; +import org.drools.spi.Constraint; +import org.drools.spi.Tuple; + +public class PredicateConstraint + implements + Constraint +{ + private final Declaration declaration; + + private final PredicateExpressionConstraint booleanExpression; + + private final Declaration[] requiredDeclarations; + + private static final Declaration[] EMPTY_DECLARATIONS = new Declaration[0]; + + public PredicateConstraint(PredicateExpressionConstraint expression, + Declaration declaration) + { + this( expression, + declaration, + null ); + } + + public PredicateConstraint(PredicateExpressionConstraint expression, + Declaration declaration, + Declaration[] declarations) + { + this.booleanExpression = expression; + + this.declaration = declaration; + + if ( declarations == null ) + { + this.requiredDeclarations = PredicateConstraint.EMPTY_DECLARATIONS; + } + else + { + this.requiredDeclarations = declarations; + } + } + + public PredicateExpressionConstraint getExpression() + { + return this.booleanExpression; + } + + public Declaration[] getRequiredDeclarations() + { + return requiredDeclarations; + } + + public Declaration getDeclaration() + { + return this.declaration; + } + + public boolean isAllowed(Object object, + FactHandle handle, + Tuple tuple) + { + return this.booleanExpression.isAllowed( object, + handle, + this.declaration, + this.requiredDeclarations, + tuple ); + } + +}; Deleted: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/spi/BooleanExpressionConstraint.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/main/java/org/drools/spi/BooleanExpressionConstraint.java 2005-12-18 23:11:49 UTC (rev 1853) +++ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/spi/BooleanExpressionConstraint.java 2005-12-19 00:06:15 UTC (rev 1854) @@ -1,14 +0,0 @@ -package org.drools.spi; - -import org.drools.FactHandle; -import org.drools.rule.Declaration; - -public interface BooleanExpressionConstraint -{ - - public boolean isAllowed(Object object, - FactHandle handle, - Declaration declaration, - Declaration[] declarations, - Tuple tuple); -} Modified: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/spi/ClassObjectType.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/main/java/org/drools/spi/ClassObjectType.java 2005-12-18 23:11:49 UTC (rev 1853) +++ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/spi/ClassObjectType.java 2005-12-19 00:06:15 UTC (rev 1854) @@ -111,6 +111,16 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /** + * Produce the hash of this object. + * + * @return The hash. + */ + public int hashCode() + { + return getType( ).hashCode( ); + } + + /** * Determine if another object is equal to this. * * @param object The object to test. @@ -131,18 +141,9 @@ } return this.objectTypeClass == ( ( ClassObjectType ) object ).objectTypeClass; - } + } + - /** - * Produce the hash of this object. - * - * @return The hash. - */ - public int hashCode() - { - return getType( ).hashCode( ); - } - public String toString() { return getType( ).getName( ); Copied: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/spi/PredicateExpressionConstraint.java (from rev 1776, trunk/labs/jbossrules/drools-core/src/main/java/org/drools/spi/BooleanExpressionConstraint.java) =================================================================== --- trunk/labs/jbossrules/drools-core/src/main/java/org/drools/spi/BooleanExpressionConstraint.java 2005-12-10 17:37:55 UTC (rev 1776) +++ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/spi/PredicateExpressionConstraint.java 2005-12-19 00:06:15 UTC (rev 1854) @@ -0,0 +1,14 @@ +package org.drools.spi; + +import org.drools.FactHandle; +import org.drools.rule.Declaration; + +public interface PredicateExpressionConstraint +{ + + public boolean isAllowed(Object object, + FactHandle handle, + Declaration declaration, + Declaration[] declarations, + Tuple tuple); +} Modified: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/spi/Tuple.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/main/java/org/drools/spi/Tuple.java 2005-12-18 23:11:49 UTC (rev 1853) +++ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/spi/Tuple.java 2005-12-19 00:06:15 UTC (rev 1854) @@ -62,7 +62,6 @@ * @return The currently bound <code>Object</code> value. */ Object get(int column); - Object get(Declaration declaration); Modified: trunk/labs/jbossrules/drools-core/src/test/java/org/drools/reteoo/JoinNodeTest.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/test/java/org/drools/reteoo/JoinNodeTest.java 2005-12-18 23:11:49 UTC (rev 1853) +++ trunk/labs/jbossrules/drools-core/src/test/java/org/drools/reteoo/JoinNodeTest.java 2005-12-19 00:06:15 UTC (rev 1854) @@ -4,10 +4,10 @@ import org.drools.DroolsTestCase; import org.drools.FactHandle; import org.drools.RetractionException; -import org.drools.rule.BooleanConstraint; +import org.drools.rule.PredicateConstraint; import org.drools.rule.Declaration; import org.drools.rule.Rule; -import org.drools.spi.BooleanExpressionConstraint; +import org.drools.spi.PredicateExpressionConstraint; import org.drools.spi.ClassObjectType; import org.drools.spi.Extractor; import org.drools.spi.ObjectType; @@ -440,7 +440,7 @@ } /** - * While all the previous tests work with the DefaultJoinNodeBinder, ie joins always succeed. This tests joins with BooleanExpressionConstraint. We only use one constraint, as Constraints are tested more thorougly else where, likewise for this + * While all the previous tests work with the DefaultJoinNodeBinder, ie joins always succeed. This tests joins with PredicateExpressionConstraint. We only use one constraint, as Constraints are tested more thorougly else where, likewise for this * reason we use a very simple constraint. * * @throws Exception @@ -473,7 +473,7 @@ 9 ); /* create the boolean expression check */ - BooleanExpressionConstraint checkString = new BooleanExpressionConstraint() { + PredicateExpressionConstraint checkString = new PredicateExpressionConstraint() { public boolean isAllowed(Object object, FactHandle handle, Declaration declaration, // ?string1 @@ -489,7 +489,7 @@ }; /* create the constraint */ - BooleanConstraint constraint = new BooleanConstraint( checkString, + PredicateConstraint constraint = new PredicateConstraint( checkString, string1Declaration, new Declaration[]{string2Declaration} ); Modified: trunk/labs/jbossrules/drools-core/src/test/java/org/drools/reteoo/NotNodeTest.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/test/java/org/drools/reteoo/NotNodeTest.java 2005-12-18 23:11:49 UTC (rev 1853) +++ trunk/labs/jbossrules/drools-core/src/test/java/org/drools/reteoo/NotNodeTest.java 2005-12-19 00:06:15 UTC (rev 1854) @@ -5,10 +5,10 @@ import org.drools.FactException; import org.drools.FactHandle; import org.drools.RetractionException; -import org.drools.rule.BooleanConstraint; +import org.drools.rule.PredicateConstraint; import org.drools.rule.Declaration; import org.drools.rule.Rule; -import org.drools.spi.BooleanExpressionConstraint; +import org.drools.spi.PredicateExpressionConstraint; import org.drools.spi.ClassObjectType; import org.drools.spi.Extractor; import org.drools.spi.ObjectType; @@ -62,7 +62,7 @@ 9 ); /* create the boolean expression check */ - BooleanExpressionConstraint checkString = new BooleanExpressionConstraint() { + PredicateExpressionConstraint checkString = new PredicateExpressionConstraint() { public boolean isAllowed(Object object, FactHandle handle, Declaration declaration, // ?string1 @@ -78,7 +78,7 @@ }; /* create the constraint */ - BooleanConstraint constraint = new BooleanConstraint( checkString, + PredicateConstraint constraint = new PredicateConstraint( checkString, string1Declaration, new Declaration[]{string2Declaration} ); Modified: trunk/labs/jbossrules/drools-core/src/test/java/org/drools/rule/ConstraintTest.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/test/java/org/drools/rule/ConstraintTest.java 2005-12-18 23:11:49 UTC (rev 1853) +++ trunk/labs/jbossrules/drools-core/src/test/java/org/drools/rule/ConstraintTest.java 2005-12-19 00:06:15 UTC (rev 1854) @@ -5,7 +5,7 @@ import org.drools.FactHandle; import org.drools.reteoo.InstrumentedReteTuple; import org.drools.reteoo.InstrumentedWorkingMemoryImpl; -import org.drools.spi.BooleanExpressionConstraint; +import org.drools.spi.PredicateExpressionConstraint; import org.drools.spi.ClassObjectType; import org.drools.spi.ConstraintComparator; import org.drools.spi.Extractor; @@ -218,7 +218,7 @@ * * </pre> */ - public void testBooleanExpressionConstraint() + public void testPredicateExpressionConstraint() { InstrumentedWorkingMemoryImpl workingMemory = new InstrumentedWorkingMemoryImpl( ); @@ -248,7 +248,7 @@ priceOfCheeseExtractor, 1 ); - BooleanExpressionConstraint isDoubleThePrice = new BooleanExpressionConstraint( ) { + PredicateExpressionConstraint isDoubleThePrice = new PredicateExpressionConstraint( ) { public boolean isAllowed(Object object, FactHandle handle, Declaration declaration, // ?price2 @@ -262,7 +262,7 @@ } }; - BooleanConstraint constraint1 = new BooleanConstraint( isDoubleThePrice, + PredicateConstraint constraint1 = new PredicateConstraint( isDoubleThePrice, price2Declaration, new Declaration[]{price1Declaration} ); Modified: trunk/labs/jbossrules/drools-core/src/test/java/org/drools/rule/LogicTransformerTest.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/test/java/org/drools/rule/LogicTransformerTest.java 2005-12-18 23:11:49 UTC (rev 1853) +++ trunk/labs/jbossrules/drools-core/src/test/java/org/drools/rule/LogicTransformerTest.java 2005-12-19 00:06:15 UTC (rev 1854) @@ -234,9 +234,9 @@ /** * This data structure is not valid - * (Exist (OR (A B) + * (Exists (OR (A B) * <pre> - * Exist + * Exists * | * or * / \ @@ -249,7 +249,7 @@ String a = "a"; String b = "b"; - Exist exist = new Exist( ); + Exists exist = new Exists( ); Or or = new Or( ); exist.addChild( or ); @@ -318,7 +318,7 @@ * / | \ / \ | * a And d e Or h * / \ / \ - * b Not f Exist + * b Not f Exists * | | * Not g * | @@ -336,7 +336,7 @@ * / | | \ / \ | * a b d Not And And i * | / \ / | - * Not e f e Exist + * Not e f e Exists * | | * c g * </pre> @@ -379,7 +379,7 @@ and3.addChild( e ); Or or1 = new Or( ); and3.addChild( or1 ); - Exist exist1 = new Exist( ); + Exists exist1 = new Exists( ); exist1.addChild( g ); or1.addChild( exist1 ); or1.addChild( h ); |
From: <jbo...@li...> - 2005-12-18 23:11:55
|
Author: wrzep Date: 2005-12-18 18:11:49 -0500 (Sun, 18 Dec 2005) New Revision: 1853 Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Plugin.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Plugins.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/KosmosStatusPlugin.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/ScorePlugin.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/StatusPlugin.java Log: removed defining plugin name (now columns define their names) http://jira.jboss.com/jira/browse/JBLAB-415 Pawel Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Plugin.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Plugin.java 2005-12-18 22:44:22 UTC (rev 1852) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Plugin.java 2005-12-18 23:11:49 UTC (rev 1853) @@ -35,23 +35,19 @@ /** Node from xml file which holds properties specyfic to this plugin */ protected Node propertiesNode; - /** Plugin name */ - protected String name; - /** Plugin id */ protected String id; /** - * @param name Plugin name * @param id Plugin id * @param propertiesNode Node with plugin specyfic properties * @throws InvalidPluginPropertiesException * Thrown when properties passed in <code>propertiesNode</code> * are incorrect or missed. */ - public void init(String name, String id, Node propertiesNode) throws InvalidPluginPropertiesException { + public void init(String id, Node propertiesNode) + throws InvalidPluginPropertiesException { this.propertiesNode = propertiesNode; - this.name = name; this.id = id; } @@ -68,10 +64,4 @@ * @return Plugin id */ public String getId() { return id; }; - - - /** - * @return Plugin name - */ - public String getName() { return name; }; } Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Plugins.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Plugins.java 2005-12-18 22:44:22 UTC (rev 1852) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Plugins.java 2005-12-18 23:11:49 UTC (rev 1853) @@ -44,7 +44,6 @@ private final static String PLUGIN_ELEMENT = "plugin"; private final static String PLUGIN_ID_ELEMENT = "id"; - private final static String PLUGIN_NAME_ELEMENT = "name"; private final static String PLUGIN_CLASS_ELEMENT = "class"; private final static String PLUGIN_PROPERTIES_ELEMENT = "properties"; @@ -94,7 +93,6 @@ // Get plugin info from pluginNode String pluginClassString = XmlTools.getChildNodeValue(pluginNode, PLUGIN_CLASS_ELEMENT); - String pluginName = XmlTools.getChildNodeValue(pluginNode, PLUGIN_NAME_ELEMENT); String pluginId = XmlTools.getChildNodeValue(pluginNode, PLUGIN_ID_ELEMENT); // Get plugin class @@ -114,9 +112,9 @@ plugin = (Plugin) pluginClass.newInstance(); if (scorePlugin) { - ((ScorePlugin) plugin).init(pluginName, pluginId, statusPlugins, pluginSpecificPropertiesNode); + ((ScorePlugin) plugin).init(pluginId, statusPlugins, pluginSpecificPropertiesNode); } else { /* status plugin */ - ((StatusPlugin) plugin).init(pluginName, pluginId, projects, pluginSpecificPropertiesNode); + ((StatusPlugin) plugin).init(pluginId, projects, pluginSpecificPropertiesNode); } } catch (InvalidPluginPropertiesException e) { Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/KosmosStatusPlugin.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/KosmosStatusPlugin.java 2005-12-18 22:44:22 UTC (rev 1852) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/KosmosStatusPlugin.java 2005-12-18 23:11:49 UTC (rev 1853) @@ -61,13 +61,10 @@ projectMaps = new HashMap<String,Map>(); } - /* (non-Javadoc) - * @see org.jboss.forge.status.plugins.StatusPlugin#init(java.lang.String, java.lang.String, org.jboss.forge.common.projects.Projects, org.w3c.dom.Node) - */ - public void init(String name, String id, Projects projects, Node propertiesNode) throws InvalidPluginPropertiesException { - super.init(name, id, projects,propertiesNode); + public void init(String id, Projects projects, + Node propertiesNode) throws InvalidPluginPropertiesException { + super.init(id, projects,propertiesNode); - getServiceProperty(propertiesNode); } @@ -77,18 +74,22 @@ * @param propertiesNode Node with plugin specyfic properties * @throws InvalidPluginPropertiesException */ - private void getServiceProperty(Node propertiesNode) throws InvalidPluginPropertiesException { - Map<String,String> properties = XmlTools.getMapFromNodeElements(propertiesNode); + private void getServiceProperty(Node propertiesNode) + throws InvalidPluginPropertiesException { + Map<String,String> properties = + XmlTools.getMapFromNodeElements(propertiesNode); if (properties.isEmpty()) { - throw new InvalidPluginPropertiesException("Missing properties for " + getName() + " plugin."); + throw new InvalidPluginPropertiesException( + "Missing properties for plugin: " + getId() + "."); } serviceURL = properties.get(getKosmosServiceProperty()); if (serviceURL == null) { throw new InvalidPluginPropertiesException( - "Missing " + getKosmosServiceProperty() + " property for " + getName() + " plugin."); + "Missing " + getKosmosServiceProperty() + + " property for plugin: " + getId() + "."); } } @@ -138,7 +139,8 @@ for (Iterator iter = map.keySet().iterator(); iter.hasNext();) { Object obj = (Object) iter.next(); - System.out.println("object: " + obj + " binding: " + map.get(obj)); + System.out.println( + "object: " + obj + " binding: " + map.get(obj)); } } } Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/ScorePlugin.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/ScorePlugin.java 2005-12-18 22:44:22 UTC (rev 1852) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/ScorePlugin.java 2005-12-18 23:11:49 UTC (rev 1853) @@ -35,8 +35,8 @@ protected Map<String,Plugin> plugins; - public void init(String name, String id, Map<String, Plugin> plugins, Node propertiesNode) throws InvalidPluginPropertiesException { + public void init(String id, Map<String, Plugin> plugins, Node propertiesNode) throws InvalidPluginPropertiesException { this.plugins = plugins; - init(name, id, propertiesNode); + init(id, propertiesNode); } } Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/StatusPlugin.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/StatusPlugin.java 2005-12-18 22:44:22 UTC (rev 1852) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/StatusPlugin.java 2005-12-18 23:11:49 UTC (rev 1853) @@ -46,8 +46,8 @@ * @param propertiesNode Node with plugin specyfic properties * @throws InvalidPluginPropertiesException */ - public void init(String name, String id, Projects projects, Node propertiesNode) throws InvalidPluginPropertiesException { + public void init(String id, Projects projects, Node propertiesNode) throws InvalidPluginPropertiesException { this.projects = projects; - init(name, id, propertiesNode); + init(id, propertiesNode); } } |
From: <jbo...@li...> - 2005-12-18 22:44:25
|
Author: wrzep Date: 2005-12-18 17:44:22 -0500 (Sun, 18 Dec 2005) New Revision: 1852 Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Plugins.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java Log: more comments http://jira.jboss.com/jira/browse/JBLAB-415 Pawel Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Plugins.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Plugins.java 2005-12-18 22:36:44 UTC (rev 1851) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Plugins.java 2005-12-18 22:44:22 UTC (rev 1852) @@ -67,8 +67,8 @@ /** * @param pluginsNode Node with plugins definitions - * @param projects Projects present in the Status Matrix. - * @param scorePlugins flag indicating whether plugins are ScorePlugins. + * @param projects Projects present in the Status Matrix + * @param scorePlugins flag indicating whether plugins are ScorePlugins */ public Plugins(Node pluginsNode, Projects projects, boolean scorePlugins) { @@ -79,9 +79,16 @@ allPlugins = new HashMap<String,Plugin>(); statusPlugins = new HashMap<String,Plugin>(); - putAll(pluginsNode, scorePlugins); + addAll(pluginsNode, scorePlugins); } + /** + * For the given Node, describing the Plugin, returns Plugin instance. + * + * @param pluginNode Node with Plugin definition + * @param scorePlugin flag indicating whether plugin should be ScorePlugin + * @return Plugin defined in the <code>pluginNode</code> + */ private Plugin getPlugin(Node pluginNode, boolean scorePlugin) { // Get plugin info from pluginNode @@ -108,7 +115,7 @@ if (scorePlugin) { ((ScorePlugin) plugin).init(pluginName, pluginId, statusPlugins, pluginSpecificPropertiesNode); - } else { /* score plugin */ + } else { /* status plugin */ ((StatusPlugin) plugin).init(pluginName, pluginId, projects, pluginSpecificPropertiesNode); } @@ -126,12 +133,22 @@ return plugin; } + /** + * @param pluginId + * @return Plugin with the given <code>pluginId</code> + */ public Plugin get(String pluginId) { return allPlugins.get(pluginId); } - public void putAll(Node pluginsNode, boolean scorePlugins) { + /** + * Adds Plugins described in the pluginsNode. + * + * @param pluginsNode Node with plugins definitions + * @param scorePlugins flag indicating whether plugins are ScorePlugins + */ + public void addAll(Node pluginsNode, boolean scorePlugins) { NodeList pluginNodes = pluginsNode.getChildNodes(); Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java 2005-12-18 22:36:44 UTC (rev 1851) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java 2005-12-18 22:44:22 UTC (rev 1852) @@ -59,7 +59,7 @@ // Get the status and score plugins plugins = new Plugins(statusPluginsRoot, projects, false); - plugins.putAll(scorePluginsRoot, true); + plugins.addAll(scorePluginsRoot, true); // Get columns to display Node pageRoot = XmlTools.getFirstNodeWithName(statusRoot, MAIN_PAGE_COLLUMNS_TAG); |
From: <jbo...@li...> - 2005-12-18 22:36:51
|
Author: wrzep Date: 2005-12-18 17:36:44 -0500 (Sun, 18 Dec 2005) New Revision: 1851 Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/InvalidPluginPropertiesException.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/KosmosStatusPlugin.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/StatusPlugin.java Log: comments, comments, comments http://jira.jboss.com/jira/browse/JBLAB-415 Pawel Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/InvalidPluginPropertiesException.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/InvalidPluginPropertiesException.java 2005-12-18 22:16:03 UTC (rev 1850) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/InvalidPluginPropertiesException.java 2005-12-18 22:36:44 UTC (rev 1851) @@ -1,5 +1,9 @@ package org.jboss.forge.status.plugins; +/** + * @author pawel + * Signals that properties passed to the plugin are missed or incorrect. + */ public class InvalidPluginPropertiesException extends Exception { public InvalidPluginPropertiesException(String msg) { Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/KosmosStatusPlugin.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/KosmosStatusPlugin.java 2005-12-18 22:16:03 UTC (rev 1850) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/KosmosStatusPlugin.java 2005-12-18 22:36:44 UTC (rev 1851) @@ -35,14 +35,21 @@ /** * @author Pawel Wrzeszcz +* Superclass for kosmos-service based plugins. */ public abstract class KosmosStatusPlugin extends StatusPlugin { protected abstract String getKosmosServiceProperty(); - private Map<String,Map> projectsMaps; + /** + * Binds project ids with kosmos-service specyfic Maps. + */ + private Map<String,Map> projectMaps; + /** + * Kosmos service adress. + */ protected String serviceURL; protected Logger log; @@ -51,17 +58,27 @@ super(); log = Logger.getLogger(this.getClass()); - projectsMaps = new HashMap<String,Map>(); + projectMaps = new HashMap<String,Map>(); } + /* (non-Javadoc) + * @see org.jboss.forge.status.plugins.StatusPlugin#init(java.lang.String, java.lang.String, org.jboss.forge.common.projects.Projects, org.w3c.dom.Node) + */ public void init(String name, String id, Projects projects, Node propertiesNode) throws InvalidPluginPropertiesException { super.init(name, id, projects,propertiesNode); - Map<String,String> properties = XmlTools.getMapFromNodeElements(propertiesNode); - getProperties(properties); + + getServiceProperty(propertiesNode); } - private void getProperties(Map<String,String> properties) throws InvalidPluginPropertiesException { + /** + * Gets service URL from the given Node with plugin properites. + * + * @param propertiesNode Node with plugin specyfic properties + * @throws InvalidPluginPropertiesException + */ + private void getServiceProperty(Node propertiesNode) throws InvalidPluginPropertiesException { + Map<String,String> properties = XmlTools.getMapFromNodeElements(propertiesNode); if (properties.isEmpty()) { throw new InvalidPluginPropertiesException("Missing properties for " + getName() + " plugin."); @@ -75,28 +92,39 @@ } } + /** + * For the given service specyfic Map, computes plugin specyfic value. + * + * @param projectMap service specyfic Map + * @return Plugin value + */ protected abstract int getPluginSpecyficValue(Map projectMap); + + + /** + * @return Default Plugin value, when service is not specified. + */ protected abstract int getPluginSpecyficDefaultValue(); + /** + * Returns service specyfic Map for the project, + * which is equals given <code>projectId</code> + * + * @param projectId + * @return service specyfic Map + */ protected abstract Map getProjectMap(String projectId); - protected void printMap(Map map) { //debug - if (map != null) { - - for (Iterator iter = map.keySet().iterator(); iter.hasNext();) { - Object obj = (Object) iter.next(); - System.out.println("object: " + obj + " binding: " + map.get(obj)); - } - } - } - + /* (non-Javadoc) + * @see org.jboss.forge.status.Plugin#getValue(java.lang.String) + */ public int getValue(String projectId) { - if (!projectsMaps.containsKey(projectId)) { - projectsMaps.put(projectId, getProjectMap(projectId)); + if (!projectMaps.containsKey(projectId)) { + projectMaps.put(projectId, getProjectMap(projectId)); } - Map projectMap = projectsMaps.get(projectId); + Map projectMap = projectMaps.get(projectId); if (projectMap == null) { return getPluginSpecyficDefaultValue(); @@ -105,4 +133,13 @@ return getPluginSpecyficValue(projectMap); } + protected void printMap(Map map) { //debug + if (map != null) { + + for (Iterator iter = map.keySet().iterator(); iter.hasNext();) { + Object obj = (Object) iter.next(); + System.out.println("object: " + obj + " binding: " + map.get(obj)); + } + } + } } Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/StatusPlugin.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/StatusPlugin.java 2005-12-18 22:16:03 UTC (rev 1850) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/StatusPlugin.java 2005-12-18 22:36:44 UTC (rev 1851) @@ -29,12 +29,23 @@ /** * @author Pawel Wrzeszcz +* Superclass for the status plugins in the Status Matrix. */ public abstract class StatusPlugin extends Plugin { + /** + * Projects present in the Status Matrix. + */ protected Projects projects; + /** + * @param name Plugin name + * @param id Plugin id + * @param projects Projects present in the Status Matrix + * @param propertiesNode Node with plugin specyfic properties + * @throws InvalidPluginPropertiesException + */ public void init(String name, String id, Projects projects, Node propertiesNode) throws InvalidPluginPropertiesException { this.projects = projects; init(name, id, propertiesNode); |
From: <jbo...@li...> - 2005-12-18 22:16:08
|
Author: wrzep Date: 2005-12-18 17:16:03 -0500 (Sun, 18 Dec 2005) New Revision: 1850 Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Plugin.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Plugins.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java Log: comments, minor implementation improvments http://jira.jboss.com/jira/browse/JBLAB-415 Pawel Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Plugin.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Plugin.java 2005-12-18 17:44:53 UTC (rev 1849) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Plugin.java 2005-12-18 22:16:03 UTC (rev 1850) @@ -27,23 +27,51 @@ /** * @author Pawel Wrzeszcz +* Superclass for Status Matrix Plugins. */ public abstract class Plugin { + /** Node from xml file which holds properties specyfic to this plugin */ protected Node propertiesNode; + /** Plugin name */ protected String name; + + /** Plugin id */ protected String id; + /** + * @param name Plugin name + * @param id Plugin id + * @param propertiesNode Node with plugin specyfic properties + * @throws InvalidPluginPropertiesException + * Thrown when properties passed in <code>propertiesNode</code> + * are incorrect or missed. + */ public void init(String name, String id, Node propertiesNode) throws InvalidPluginPropertiesException { this.propertiesNode = propertiesNode; this.name = name; this.id = id; } + /** + * For the given project returns value specyfic to this plugin. + * + * @param projectId project id + * @return value computed by plugin for the project + * with the given <code>projectId</code>. + */ public abstract int getValue(String projectId); + /** + * @return Plugin id + */ public String getId() { return id; }; + + + /** + * @return Plugin name + */ public String getName() { return name; }; } Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Plugins.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Plugins.java 2005-12-18 17:44:53 UTC (rev 1849) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Plugins.java 2005-12-18 22:16:03 UTC (rev 1850) @@ -36,6 +36,7 @@ /** * @author Pawel Wrzeszcz +* A class handling plugins used by the Status Matrix. */ public class Plugins {; @@ -47,26 +48,41 @@ private final static String PLUGIN_CLASS_ELEMENT = "class"; private final static String PLUGIN_PROPERTIES_ELEMENT = "properties"; - Map<String, Plugin> plugins; + /** + * All plugins stored in this class. + */ + Map<String, Plugin> allPlugins; + + /** + * All status plugins stored in this class. + */ Map<String, Plugin> statusPlugins; + /** + * Projects present in the Status Matrix. + */ Projects projects; private Logger log; - public Plugins(NodeList pluginNodes, Projects projects, boolean scorePlugins) { + /** + * @param pluginsNode Node with plugins definitions + * @param projects Projects present in the Status Matrix. + * @param scorePlugins flag indicating whether plugins are ScorePlugins. + */ + public Plugins(Node pluginsNode, Projects projects, boolean scorePlugins) { this.projects = projects; log = Logger.getLogger(this.getClass()); - plugins = new HashMap<String,Plugin>(); + allPlugins = new HashMap<String,Plugin>(); statusPlugins = new HashMap<String,Plugin>(); - putAll(pluginNodes, scorePlugins); + putAll(pluginsNode, scorePlugins); } -private Plugin getPlugin(Node pluginNode, boolean scorePlugin) { + private Plugin getPlugin(Node pluginNode, boolean scorePlugin) { // Get plugin info from pluginNode @@ -112,11 +128,13 @@ public Plugin get(String pluginId) { - return plugins.get(pluginId); + return allPlugins.get(pluginId); } - public void putAll(NodeList pluginNodes, boolean scorePlugins) { + public void putAll(Node pluginsNode, boolean scorePlugins) { + NodeList pluginNodes = pluginsNode.getChildNodes(); + for (int i = 0; i < pluginNodes.getLength(); i++) { Node pluginNode = pluginNodes.item(i); @@ -127,7 +145,7 @@ Plugin plugin = getPlugin(pluginNode, scorePlugins); if (plugin != null) { - plugins.put(plugin.getId(), plugin); + allPlugins.put(plugin.getId(), plugin); if (!scorePlugins) { statusPlugins.put(plugin.getId(), plugin); } Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java 2005-12-18 17:44:53 UTC (rev 1849) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java 2005-12-18 22:16:03 UTC (rev 1850) @@ -31,7 +31,6 @@ import org.jboss.portal.common.context.DelegateContext; import org.w3c.dom.Node; -import org.w3c.dom.NodeList; /** @@ -58,14 +57,10 @@ // Get the projects Projects projects = ProjectsHelper.getProjects(portalName); - // Get the status plugins - NodeList statusPluginsNodes = statusPluginsRoot.getChildNodes(); - plugins = new Plugins(statusPluginsNodes, projects, false); + // Get the status and score plugins + plugins = new Plugins(statusPluginsRoot, projects, false); + plugins.putAll(scorePluginsRoot, true); - // Add the score plugins - NodeList scorePluginsNodes = scorePluginsRoot.getChildNodes(); - plugins.putAll(scorePluginsNodes, true); - // Get columns to display Node pageRoot = XmlTools.getFirstNodeWithName(statusRoot, MAIN_PAGE_COLLUMNS_TAG); mainPageColumns = new Columns(pageRoot, plugins, projects); |
From: <jbo...@li...> - 2005-12-18 17:45:00
|
Author: aron.gombas Date: 2005-12-18 12:44:53 -0500 (Sun, 18 Dec 2005) New Revision: 1849 Modified: trunk/labs/kosmos/web-portlet/pages/svn_monitoring_revision_details.jsp Log: Coloring fixed Modified: trunk/labs/kosmos/web-portlet/pages/svn_monitoring_revision_details.jsp =================================================================== --- trunk/labs/kosmos/web-portlet/pages/svn_monitoring_revision_details.jsp 2005-12-18 17:44:04 UTC (rev 1848) +++ trunk/labs/kosmos/web-portlet/pages/svn_monitoring_revision_details.jsp 2005-12-18 17:44:53 UTC (rev 1849) @@ -4,7 +4,7 @@ <fmt:setBundle basename="hu.midori.kosmos.portlet.svn.svn_monitoring" scope="application"/> <table> - <tr class="portlet-section-alternate"> + <tr class="portlet-section-body"> <td><fmt:message key="svnrepository.mostActiveCommitters"/>:</td> <td><img src="<c:out value="${repository.commitsPerAuthorChartUrl}"/>" title="<fmt:message key="svnrepository.mostActiveCommitters"/>"/></td> <td valign="top"> @@ -17,10 +17,10 @@ <c:forEach var="item" items="${repository.commitsPerAuthor}" varStatus="status"> <c:choose> <c:when test="${status.index < 10}"> - <tr id="row-<portlet:namespace/>-0-<c:out value="${status.index}"/>" class="portlet-section-body"> + <tr id="row-<portlet:namespace/>-0-<c:out value="${status.index}"/>" class="portlet-section-alternate"> </c:when> <c:otherwise> - <tr id="row-<portlet:namespace/>-0-<c:out value="${status.index}"/>" style="display: none" class="portlet-section-body"> + <tr id="row-<portlet:namespace/>-0-<c:out value="${status.index}"/>" style="display: none" class="portlet-section-alternate"> </c:otherwise> </c:choose> <td><c:out value="${1 + status.index}"/></td> @@ -31,7 +31,7 @@ </table> </td> </tr> - <tr class="portlet-section-body"> + <tr class="portlet-section-alternate"> <td valign="top"><fmt:message key="svnrepository.mostActiveFiles"/>:</td> <td valign="top"><img src="<c:out value="${repository.commitsPerFileChartUrl}"/>" title="<fmt:message key="svnrepository.mostActiveFiles"/>"/></td> <td valign="top"> @@ -44,10 +44,10 @@ <c:forEach var="item" items="${repository.commitsPerFile}" varStatus="status"> <c:choose> <c:when test="${status.index < 10}"> - <tr id="row-<portlet:namespace/>-1-<c:out value="${status.index}"/>" class="portlet-section-alternate"> + <tr id="row-<portlet:namespace/>-1-<c:out value="${status.index}"/>" class="portlet-section-body"> </c:when> <c:otherwise> - <tr id="row-<portlet:namespace/>-1-<c:out value="${status.index}"/>" style="display: none" class="portlet-section-alternate"> + <tr id="row-<portlet:namespace/>-1-<c:out value="${status.index}"/>" style="display: none" class="portlet-section-body"> </c:otherwise> </c:choose> <td><c:out value="${1 + status.index}"/></td> |
From: <jbo...@li...> - 2005-12-18 17:44:16
|
Author: aron.gombas Date: 2005-12-18 12:44:04 -0500 (Sun, 18 Dec 2005) New Revision: 1848 Modified: trunk/labs/kosmos/web-portlet/pages/images/kosmos_logo.png Log: New logo Modified: trunk/labs/kosmos/web-portlet/pages/images/kosmos_logo.png =================================================================== (Binary files differ) |
From: <jbo...@li...> - 2005-12-18 15:35:23
|
Author: wrzep Date: 2005-12-18 10:35:18 -0500 (Sun, 18 Dec 2005) New Revision: 1847 Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Columns.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java Log: comments, minor code improvments http://jira.jboss.com/jira/browse/JBLAB-415 Pawel Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Columns.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Columns.java 2005-12-18 15:18:30 UTC (rev 1846) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Columns.java 2005-12-18 15:35:18 UTC (rev 1847) @@ -23,7 +23,6 @@ package org.jboss.forge.status; import java.util.ArrayList; -import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.Set; @@ -39,12 +38,21 @@ /** * @author Pawel Wrzeszcz +* A class holding column information about columns on the one page to display. */ public class Columns { - List<Column> columns; - Projects projects; + /** Status Matrix Columns list (Column order matters) */ + private List<Column> columns; + /** Projects present in the Status Matrix */ + private Projects projects; + + /** + * @param pageRoot root Node specfying Columns to display + * @param plugins Plugins used by Columns + * @param projects Projects present in the Status Matrix + */ public Columns(Node pageRoot, Plugins plugins, Projects projects) { this.projects = projects; @@ -66,11 +74,21 @@ } } + /** + * Fills the given context with columns information + * + * @param context DelegateContext to fill + */ public void fillContext(DelegateContext context) { fillColumnsNames(context); fillValues(context); } + /** + * Fills the given context with column names + * + * @param context DelegateContext to fill + */ private void fillColumnsNames(DelegateContext context) { for (Iterator iter = columns.iterator(); iter.hasNext();) { @@ -83,7 +101,11 @@ } } - /** Fills the context with appropiate values (from each column) for each project. */ + /** Fills the given context with the cell values + * (for each column and for each project). + * + * @param context DelegateContext to fill + */ private void fillValues(DelegateContext context) { Set<String> projectIds = projects.getProjectIds( @@ -95,10 +117,20 @@ position++; DelegateContext projectContext = context.next("project"); + fillProjectContext(projectContext, projectId, position); + fillEntries(projectContext, projectId); } + //TODO sorting } + /** + * Fills the given context with the project informationcell value + * + * @param projectContext DelegateContext to fill + * @param projectId project id + * @param position Project posistion in the Status Matrix + */ private void fillProjectContext(DelegateContext projectContext, String projectId, int position) { @@ -106,11 +138,16 @@ projectContext.put("name", projects.getProjectName(projectId)); projectContext.put("link", projects.getProjectLink(projectId)); - - fillEntries(projectContext, columns, projectId); } - private void fillEntries(DelegateContext projectContext, Collection<Column> columns, String projectId) { + /** + * Fills the given context with the cells information in the project row + * + * @param projectId specifies project row + * @param projectContext DelegateContext to fill + */ + private void fillEntries(DelegateContext projectContext, String projectId) { + for (Iterator iter = columns.iterator(); iter.hasNext();) { Column column = (Column) iter.next(); Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java 2005-12-18 15:18:30 UTC (rev 1846) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java 2005-12-18 15:35:18 UTC (rev 1847) @@ -74,7 +74,7 @@ /** * Fills the given context with the Status Matrix information. * - * @param context Context to fill. + * @param context DelegateContext to fill. */ public void fillContext(DelegateContext context) { mainPageColumns.fillContext(context); |
From: <jbo...@li...> - 2005-12-18 15:18:40
|
Author: aron.gombas Date: 2005-12-18 10:18:30 -0500 (Sun, 18 Dec 2005) New Revision: 1846 Modified: trunk/labs/kosmos/build-distro.xml Log: Preconf distro package generation almost complete Modified: trunk/labs/kosmos/build-distro.xml =================================================================== --- trunk/labs/kosmos/build-distro.xml 2005-12-18 15:15:02 UTC (rev 1845) +++ trunk/labs/kosmos/build-distro.xml 2005-12-18 15:18:30 UTC (rev 1846) @@ -21,7 +21,7 @@ <property name="distro-bin-exo.name" value="${distro-bin.name}-for-exo"/> <property name="distro-bin-gridsphere.name" value="${distro-bin.name}-for-gridsphere"/> <property name="distro-bin-jboss-portal.name" value="${distro-bin.name}-for-jboss-portal"/> - <property name="distro-bin-liferay.name" value="${distro-bin.name}-for-liferay"/> + <property name="distro-bin-liferay-portal.name" value="${distro-bin.name}-for-liferay-portal"/> <!-- generated paths --> <property name="src.dir" location="src"/> @@ -39,7 +39,7 @@ <property name="dist-bin-exo.dir" location="${dist.dir}/${distro-bin-exo.name}"/> <property name="dist-bin-gridsphere.dir" location="${dist.dir}/${distro-bin-gridsphere.name}"/> <property name="dist-bin-jboss-portal.dir" location="${dist.dir}/${distro-bin-jboss-portal.name}"/> - <property name="dist-bin-liferay.dir" location="${dist.dir}/${distro-bin-liferay.name}"/> + <property name="dist-bin-liferay-portal.dir" location="${dist.dir}/${distro-bin-liferay-portal.name}"/> <property name="xdocs.dir" location="xdocs"/> <property name="reference.dir" location="${xdocs.dir}/reference"/> @@ -56,7 +56,7 @@ <delete dir="${dist.dir}"/> </target> - <target name="dist" depends="init,clean,dist-bin,dist-src,dist-bin-exo,dist-bin-gridsphere,dist-bin-jboss-portal,dist-bin-liferay" description="Prepares all distributables"/> + <target name="dist" depends="init,clean,dist-bin,dist-src,dist-bin-exo,dist-bin-gridsphere,dist-bin-jboss-portal,dist-bin-liferay-portal" description="Prepares all distributables"/> <!-- generic distribution package targets --> <target name="dist-bin" depends="init,clean,manual" description="Prepares all binary distributables"> @@ -156,8 +156,9 @@ <mkdir dir="${dist-bin-exo.dir}"/> <!-- deploy --> - <!-- set CATALINA_HOME --> - <!-- TODO call 2x deploy --> + <!-- TODO set CATALINA_HOME --> + <ant antfile="${dist-bin.dir}/portlet/deploy-portlet-exo.xml" dir="${dist-bin.dir}/portlet"/> + <ant antfile="${dist-bin.dir}/server/deploy-server-tomcat.xml" dir="${dist-bin.dir}/server"/> <!-- copy all webapps --> <copy todir="${dist-bin-exo.dir}/webapps"> @@ -181,8 +182,9 @@ <mkdir dir="${dist-bin-gridsphere.dir}"/> <!-- deploy --> - <!-- set CATALINA_HOME --> - <!-- TODO call 2x deploy --> + <!-- TODO set CATALINA_HOME --> + <ant antfile="${dist-bin.dir}/portlet/deploy-portlet-gridsphere.xml" dir="${dist-bin.dir}/portlet"/> + <ant antfile="${dist-bin.dir}/server/deploy-server-tomcat.xml" dir="${dist-bin.dir}/server"/> <!-- copy all webapps --> <copy todir="${dist-bin-gridsphere.dir}/webapps"> @@ -206,7 +208,8 @@ <mkdir dir="${dist-bin-jboss-portal.dir}"/> <!-- deploy --> - <!-- TODO call 2x deploy --> + <ant antfile="${dist-bin.dir}/portlet/deploy-portlet-jboss-portal.xml" dir="${dist-bin.dir}/portlet"/> + <ant antfile="${dist-bin.dir}/server/deploy-server-jboss-as.xml" dir="${dist-bin.dir}/server"/> <!-- copy all webapps --> <mkdir dir="${dist-bin-jboss-portal.dir}/deploy"/> @@ -227,28 +230,29 @@ <tar destfile="${dist.dir}/${distro-bin-jboss-portal.name}.tar.gz" basedir="${dist.dir}" includes="${distro-bin-jboss-portal.name}/**" compression="gzip" longfile="gnu"/> </target> - <target name="dist-bin-liferay" depends="dist-bin" description="Prepares all binary distributables for Liferay"> - <mkdir dir="${dist-bin-liferay.dir}"/> + <target name="dist-bin-liferay-portal" depends="dist-bin" description="Prepares all binary distributables for Liferay"> + <mkdir dir="${dist-bin-liferay-portal.dir}"/> <!-- deploy --> - <!-- set CATALINA_HOME --> - <!-- TODO call 2x deploy --> + <!-- TODO set CATALINA_HOME --> + <ant antfile="${dist-bin.dir}/portlet/deploy-portlet-liferay-portal.xml" dir="${dist-bin.dir}/portlet"/> + <ant antfile="${dist-bin.dir}/server/deploy-server-tomcat.xml" dir="${dist-bin.dir}/server"/> <!-- copy all webapps --> - <copy todir="${dist-bin-liferay.dir}/webapps"> + <copy todir="${dist-bin-liferay-portal.dir}/webapps"> <fileset dir="${env.CATALINA_HOME}/webapps" includes="kosmos-portlet/**/*"/> <fileset dir="${env.CATALINA_HOME}/webapps" includes="kosmos-server/**/*"/> <fileset dir="${env.CATALINA_HOME}/webapps" includes="slide/**/*"/> </copy> <!-- copy all documents --> - <copy todir="${dist-bin-liferay.dir}"> + <copy todir="${dist-bin-liferay-portal.dir}"> <fileset dir="${dist-bin.dir}" includes="docs/**/*"/> <fileset dir="${dist-bin.dir}" includes="*.*"/> </copy> <!-- pack --> - <zip file="${dist.dir}/${distro-bin-liferay.name}.zip" basedir="${dist.dir}" includes="${distro-bin-liferay.name}/**"/> - <tar destfile="${dist.dir}/${distro-bin-liferay.name}.tar.gz" basedir="${dist.dir}" includes="${distro-bin-liferay.name}/**" compression="gzip" longfile="gnu"/> + <zip file="${dist.dir}/${distro-bin-liferay-portal.name}.zip" basedir="${dist.dir}" includes="${distro-bin-liferay-portal.name}/**"/> + <tar destfile="${dist.dir}/${distro-bin-liferay-portal.name}.tar.gz" basedir="${dist.dir}" includes="${distro-bin-liferay-portal.name}/**" compression="gzip" longfile="gnu"/> </target> </project> |
From: <jbo...@li...> - 2005-12-18 15:15:32
|
Author: wrzep Date: 2005-12-18 10:15:02 -0500 (Sun, 18 Dec 2005) New Revision: 1845 Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Column.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java Log: comments http://jira.jboss.com/jira/browse/JBLAB-415 Pawel Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Column.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Column.java 2005-12-18 14:45:47 UTC (rev 1844) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Column.java 2005-12-18 15:15:02 UTC (rev 1845) @@ -26,22 +26,40 @@ /** * @author Pawel Wrzeszcz +* A class holding column information in the Status Matrix. */ public class Column { + /** Column name */ String name; + + /** Plugin used to generate values in project rows */ Plugin plugin; + /** + * @param name Column name + * @param plugin Plugin to be used to generate values in project rows + */ public Column(String name, Plugin plugin) { this.name = name; this.plugin = plugin; System.out.println("Column " + name + " / " + (plugin == null ? "null" : plugin.getId())); } + /** + * @return Column name + */ public String getName() { return name; } + /** + * Fills the given context with the appropiate Status Matrix cell, + * located in the project row and this column. + * + * @param projectContext context to fill + * @param projectId id of the project to fill value for + */ public void fillProjectContext(DelegateContext projectContext, String projectId) { DelegateContext entryContext = projectContext.next("entry"); entryContext.put("value", plugin.getValue(projectId)); Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java 2005-12-18 14:45:47 UTC (rev 1844) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java 2005-12-18 15:15:02 UTC (rev 1845) @@ -22,9 +22,6 @@ package org.jboss.forge.status; -import java.util.Set; -import java.util.HashSet; - import org.jboss.forge.common.projects.Projects; import org.jboss.forge.common.projects.ProjectsHelper; @@ -39,22 +36,27 @@ /** * @author Pawel Wrzeszcz +* A class which handles Status Matrix information managment. */ public class Status extends AbstractDescriptor { private static final String MAIN_PAGE_COLLUMNS_TAG = "main"; - //private static final String PROJECT_PAGE_COLLUMNS_TAG = "project"; + //private static final String PROJECT_PAGE_COLLUMNS_TAG = "project"; + //TODO displaying project-specyfic pages - private Projects projects; - + /** Columns to display on the main page */ private Columns mainPageColumns; + + /* Columns to display on the project specyfic page */ + //private Columns projectPageColumns; + /** Plugins used in the Status Matrix */ private Plugins plugins; Status(String portalName, Node statusRoot, Node statusPluginsRoot, Node scorePluginsRoot) { // Get the projects - projects = ProjectsHelper.getProjects(portalName); + Projects projects = ProjectsHelper.getProjects(portalName); // Get the status plugins NodeList statusPluginsNodes = statusPluginsRoot.getChildNodes(); @@ -70,11 +72,11 @@ } /** - * Fills the given context with podcast information. + * Fills the given context with the Status Matrix information. * * @param context Context to fill. */ public void fillContext(DelegateContext context) { mainPageColumns.fillContext(context); } -} +} \ No newline at end of file |
From: <jbo...@li...> - 2005-12-18 14:45:57
|
Author: wrzep Date: 2005-12-18 09:45:47 -0500 (Sun, 18 Dec 2005) New Revision: 1844 Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Plugins.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java Log: switched to use XmlTools instead of my own parsing functions http://jira.jboss.com/jira/browse/JBLAB-415 Pawel Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Plugins.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Plugins.java 2005-12-18 14:27:51 UTC (rev 1843) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Plugins.java 2005-12-18 14:45:47 UTC (rev 1844) @@ -23,10 +23,7 @@ package org.jboss.forge.status; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; -import java.util.Set; - import org.jboss.forge.common.XmlTools; import org.jboss.forge.common.projects.Projects; import org.jboss.forge.status.plugins.InvalidPluginPropertiesException; @@ -35,6 +32,7 @@ import org.jboss.logging.Logger; import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** * @author Pawel Wrzeszcz @@ -42,6 +40,8 @@ public class Plugins {; + private final static String PLUGIN_ELEMENT = "plugin"; + private final static String PLUGIN_ID_ELEMENT = "id"; private final static String PLUGIN_NAME_ELEMENT = "name"; private final static String PLUGIN_CLASS_ELEMENT = "class"; @@ -54,7 +54,7 @@ private Logger log; - public Plugins(Set<Node> pluginsNodes, Projects projects, boolean scorePlugins) { + public Plugins(NodeList pluginNodes, Projects projects, boolean scorePlugins) { this.projects = projects; @@ -63,7 +63,7 @@ plugins = new HashMap<String,Plugin>(); statusPlugins = new HashMap<String,Plugin>(); - putAll(pluginsNodes, scorePlugins); + putAll(pluginNodes, scorePlugins); } private Plugin getPlugin(Node pluginNode, boolean scorePlugin) { @@ -111,12 +111,18 @@ } public Plugin get(String pluginId) { + return plugins.get(pluginId); } - public void putAll(Set<Node> pluginsNodes, boolean scorePlugins) { - for (Iterator iter = pluginsNodes.iterator(); iter.hasNext();) { - Node pluginNode = (Node) iter.next(); + public void putAll(NodeList pluginNodes, boolean scorePlugins) { + + for (int i = 0; i < pluginNodes.getLength(); i++) { + Node pluginNode = pluginNodes.item(i); + + if (pluginNode.getNodeName() != PLUGIN_ELEMENT) { + continue; + } Plugin plugin = getPlugin(pluginNode, scorePlugins); Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java 2005-12-18 14:27:51 UTC (rev 1843) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java 2005-12-18 14:45:47 UTC (rev 1844) @@ -41,8 +41,6 @@ * @author Pawel Wrzeszcz */ public class Status extends AbstractDescriptor { - - private final static String PLUGIN_ELEMENT = "plugin"; private static final String MAIN_PAGE_COLLUMNS_TAG = "main"; //private static final String PROJECT_PAGE_COLLUMNS_TAG = "project"; @@ -55,39 +53,22 @@ Status(String portalName, Node statusRoot, Node statusPluginsRoot, Node scorePluginsRoot) { - System.out.println("# 1 #"); - // Get the projects projects = ProjectsHelper.getProjects(portalName); // Get the status plugins - Set<Node> statusPluginsNodes = getPluginsNodes(statusPluginsRoot); + NodeList statusPluginsNodes = statusPluginsRoot.getChildNodes(); plugins = new Plugins(statusPluginsNodes, projects, false); - System.out.println("# 2 #"); - // Add the score plugins - Set<Node> scorePluginsNodes = getPluginsNodes(scorePluginsRoot); + NodeList scorePluginsNodes = scorePluginsRoot.getChildNodes(); plugins.putAll(scorePluginsNodes, true); - System.out.println("# 3 #"); - // Get columns to display Node pageRoot = XmlTools.getFirstNodeWithName(statusRoot, MAIN_PAGE_COLLUMNS_TAG); mainPageColumns = new Columns(pageRoot, plugins, projects); - - System.out.println("# 4 #"); } - private Set<Node> getPluginsNodes(Node pluginsRoot) { - - HashSet<String> pluginElementSet = new HashSet<String>(); - pluginElementSet.add(PLUGIN_ELEMENT); - Set<Node> pluginsNodes = getChildNodesSet(pluginsRoot, pluginElementSet); - - return pluginsNodes; - } - /** * Fills the given context with podcast information. * @@ -96,29 +77,4 @@ public void fillContext(DelegateContext context) { mainPageColumns.fillContext(context); } - - /** - * For the given Node, computes Set of it's child Nodes. - * Only child Nodes with names included in <code>nodesNames</code> Set - * appear in computed Set. - * - * @param root - * @param nodesNames - * @return Set containing <code>root</code>'s child Nodes, - * but only those with names included in <code>nodeNames</code> Set - */ - private Set<Node> getChildNodesSet(Node root, Set<String> nodesNames) { - HashSet<Node> ret = new HashSet<Node>(); - NodeList list = root.getChildNodes(); - - for (int i = 0; i < list.getLength(); i++) { - Node n = list.item(i); - if ((n.getNodeType() == Node.ELEMENT_NODE) - && (nodesNames.contains(n.getNodeName()))) { - ret.add(n); - } - } - - return ret; - } } |
From: <jbo...@li...> - 2005-12-18 14:27:57
|
Author: wrzep Date: 2005-12-18 09:27:51 -0500 (Sun, 18 Dec 2005) New Revision: 1843 Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Plugins.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/ScorePlugin.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/WeightedScorePlugin.java Log: after moving everything about plugins to Plugins class, ScorePlugins didn't work - fixed http://jira.jboss.com/jira/browse/JBLAB-415 Pawel Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Plugins.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Plugins.java 2005-12-18 13:55:48 UTC (rev 1842) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Plugins.java 2005-12-18 14:27:51 UTC (rev 1843) @@ -48,6 +48,8 @@ private final static String PLUGIN_PROPERTIES_ELEMENT = "properties"; Map<String, Plugin> plugins; + Map<String, Plugin> statusPlugins; + Projects projects; private Logger log; @@ -59,8 +61,9 @@ log = Logger.getLogger(this.getClass()); plugins = new HashMap<String,Plugin>(); + statusPlugins = new HashMap<String,Plugin>(); - add(pluginsNodes, scorePlugins); + putAll(pluginsNodes, scorePlugins); } private Plugin getPlugin(Node pluginNode, boolean scorePlugin) { @@ -88,7 +91,7 @@ plugin = (Plugin) pluginClass.newInstance(); if (scorePlugin) { - ((ScorePlugin) plugin).init(pluginName, pluginId, plugins.values(), pluginSpecificPropertiesNode); + ((ScorePlugin) plugin).init(pluginName, pluginId, statusPlugins, pluginSpecificPropertiesNode); } else { /* score plugin */ ((StatusPlugin) plugin).init(pluginName, pluginId, projects, pluginSpecificPropertiesNode); } @@ -111,7 +114,7 @@ return plugins.get(pluginId); } - public void add(Set<Node> pluginsNodes, boolean scorePlugins) { + public void putAll(Set<Node> pluginsNodes, boolean scorePlugins) { for (Iterator iter = pluginsNodes.iterator(); iter.hasNext();) { Node pluginNode = (Node) iter.next(); @@ -119,6 +122,9 @@ if (plugin != null) { plugins.put(plugin.getId(), plugin); + if (!scorePlugins) { + statusPlugins.put(plugin.getId(), plugin); + } } } } Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java 2005-12-18 13:55:48 UTC (rev 1842) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java 2005-12-18 14:27:51 UTC (rev 1843) @@ -68,7 +68,7 @@ // Add the score plugins Set<Node> scorePluginsNodes = getPluginsNodes(scorePluginsRoot); - //plugins.putAll(scorePluginsNodes, true); + plugins.putAll(scorePluginsNodes, true); System.out.println("# 3 #"); Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/ScorePlugin.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/ScorePlugin.java 2005-12-18 13:55:48 UTC (rev 1842) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/ScorePlugin.java 2005-12-18 14:27:51 UTC (rev 1843) @@ -22,7 +22,7 @@ package org.jboss.forge.status.plugins; -import java.util.Collection; +import java.util.Map; import org.jboss.forge.status.Plugin; import org.w3c.dom.Node; @@ -33,9 +33,9 @@ public abstract class ScorePlugin extends Plugin { - protected Collection<Plugin> plugins; + protected Map<String,Plugin> plugins; - public void init(String name, String id, Collection<Plugin> plugins, Node propertiesNode) throws InvalidPluginPropertiesException { + public void init(String name, String id, Map<String, Plugin> plugins, Node propertiesNode) throws InvalidPluginPropertiesException { this.plugins = plugins; init(name, id, propertiesNode); } Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/WeightedScorePlugin.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/WeightedScorePlugin.java 2005-12-18 13:55:48 UTC (rev 1842) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/WeightedScorePlugin.java 2005-12-18 14:27:51 UTC (rev 1843) @@ -39,7 +39,7 @@ public int getValue(String projectId) { int total = 0; - for (Iterator iter = plugins.iterator(); iter.hasNext();) { + for (Iterator iter = plugins.values().iterator(); iter.hasNext();) { Plugin plugin = (Plugin) iter.next(); total += plugin.getValue(projectId); // TODO weights |
From: <jbo...@li...> - 2005-12-18 13:55:54
|
Author: aron.gombas Date: 2005-12-18 08:55:48 -0500 (Sun, 18 Dec 2005) New Revision: 1842 Modified: trunk/labs/kosmos/build-distro.xml Log: Skeleton for all portal vendor preconfig packaging Modified: trunk/labs/kosmos/build-distro.xml =================================================================== --- trunk/labs/kosmos/build-distro.xml 2005-12-18 13:55:10 UTC (rev 1841) +++ trunk/labs/kosmos/build-distro.xml 2005-12-18 13:55:48 UTC (rev 1842) @@ -18,7 +18,10 @@ <property file="build/kosmos-project.properties"/> <property name="distro-bin.name" value="${project.name.short}-${project.version}"/> <property name="distro-src.name" value="${project.name.short}-src-${project.version}"/> + <property name="distro-bin-exo.name" value="${distro-bin.name}-for-exo"/> + <property name="distro-bin-gridsphere.name" value="${distro-bin.name}-for-gridsphere"/> <property name="distro-bin-jboss-portal.name" value="${distro-bin.name}-for-jboss-portal"/> + <property name="distro-bin-liferay.name" value="${distro-bin.name}-for-liferay"/> <!-- generated paths --> <property name="src.dir" location="src"/> @@ -33,7 +36,10 @@ <property name="dist-src.dir" location="${dist.dir}/${distro-src.name}"/> <property name="dist-src.docs.api.dir" location="${dist-src.dir}/docs/api"/> + <property name="dist-bin-exo.dir" location="${dist.dir}/${distro-bin-exo.name}"/> + <property name="dist-bin-gridsphere.dir" location="${dist.dir}/${distro-bin-gridsphere.name}"/> <property name="dist-bin-jboss-portal.dir" location="${dist.dir}/${distro-bin-jboss-portal.name}"/> + <property name="dist-bin-liferay.dir" location="${dist.dir}/${distro-bin-liferay.name}"/> <property name="xdocs.dir" location="xdocs"/> <property name="reference.dir" location="${xdocs.dir}/reference"/> @@ -51,7 +57,8 @@ </target> <target name="dist" depends="init,clean,dist-bin,dist-src,dist-bin-exo,dist-bin-gridsphere,dist-bin-jboss-portal,dist-bin-liferay" description="Prepares all distributables"/> - + + <!-- generic distribution package targets --> <target name="dist-bin" depends="init,clean,manual" description="Prepares all binary distributables"> <!-- prepare subprojects --> <ant antfile="build-portlet.xml" target="dist-bin" inheritall="false"/> @@ -144,31 +151,74 @@ </java> </target> + <!-- portlet container specific distribution package targets --> <target name="dist-bin-exo" depends="dist-bin" description="Prepares all binary distributables for eXo"> -<!-- TODO implement --> + <mkdir dir="${dist-bin-exo.dir}"/> + + <!-- deploy --> + <!-- set CATALINA_HOME --> + <!-- TODO call 2x deploy --> + + <!-- copy all webapps --> + <copy todir="${dist-bin-exo.dir}/webapps"> + <fileset dir="${env.CATALINA_HOME}/webapps" includes="kosmos-portlet/**/*"/> + <fileset dir="${env.CATALINA_HOME}/webapps" includes="kosmos-server/**/*"/> + <fileset dir="${env.CATALINA_HOME}/webapps" includes="slide/**/*"/> + </copy> + + <!-- copy all documents --> + <copy todir="${dist-bin-exo.dir}"> + <fileset dir="${dist-bin.dir}" includes="docs/**/*"/> + <fileset dir="${dist-bin.dir}" includes="*.*"/> + </copy> + + <!-- pack --> + <zip file="${dist.dir}/${distro-bin-exo.name}.zip" basedir="${dist.dir}" includes="${distro-bin-exo.name}/**"/> + <tar destfile="${dist.dir}/${distro-bin-exo.name}.tar.gz" basedir="${dist.dir}" includes="${distro-bin-exo.name}/**" compression="gzip" longfile="gnu"/> </target> <target name="dist-bin-gridsphere" depends="dist-bin" description="Prepares all binary distributables for Gridsphere"> -<!-- TODO implement --> + <mkdir dir="${dist-bin-gridsphere.dir}"/> + + <!-- deploy --> + <!-- set CATALINA_HOME --> + <!-- TODO call 2x deploy --> + + <!-- copy all webapps --> + <copy todir="${dist-bin-gridsphere.dir}/webapps"> + <fileset dir="${env.CATALINA_HOME}/webapps" includes="kosmos-portlet/**/*"/> + <fileset dir="${env.CATALINA_HOME}/webapps" includes="kosmos-server/**/*"/> + <fileset dir="${env.CATALINA_HOME}/webapps" includes="slide/**/*"/> + </copy> + + <!-- copy all documents --> + <copy todir="${dist-bin-gridsphere.dir}"> + <fileset dir="${dist-bin.dir}" includes="docs/**/*"/> + <fileset dir="${dist-bin.dir}" includes="*.*"/> + </copy> + + <!-- pack --> + <zip file="${dist.dir}/${distro-bin-gridsphere.name}.zip" basedir="${dist.dir}" includes="${distro-bin-gridsphere.name}/**"/> + <tar destfile="${dist.dir}/${distro-bin-gridsphere.name}.tar.gz" basedir="${dist.dir}" includes="${distro-bin-gridsphere.name}/**" compression="gzip" longfile="gnu"/> </target> <target name="dist-bin-jboss-portal" depends="dist-bin" description="Prepares all binary distributables for JBoss Portal"> <mkdir dir="${dist-bin-jboss-portal.dir}"/> <!-- deploy --> - <!-- TODO call 2x deploy --> + <!-- TODO call 2x deploy --> - <!-- copy all webapps --> + <!-- copy all webapps --> <mkdir dir="${dist-bin-jboss-portal.dir}/deploy"/> - <copy todir="${dist-bin-jboss-portal.dir}/deploy"> + <copy todir="${dist-bin-jboss-portal.dir}/deploy"> <fileset dir="${env.JBOSS_HOME}/server/default/deploy" includes="kosmos-portlet.war/**/*"/> <fileset dir="${env.JBOSS_HOME}/server/default/deploy" includes="kosmos-server.war/**/*"/> <fileset dir="${env.JBOSS_HOME}/server/default/deploy" includes="slide.war/**/*"/> - </copy> + </copy> - <!-- copy all documents --> - <copy todir="${dist-bin-jboss-portal.dir}"> - <fileset dir="${dist-bin.dir}" includes="docs/**/*"/> + <!-- copy all documents --> + <copy todir="${dist-bin-jboss-portal.dir}"> + <fileset dir="${dist-bin.dir}" includes="docs/**/*"/> <fileset dir="${dist-bin.dir}" includes="*.*"/> </copy> @@ -178,7 +228,27 @@ </target> <target name="dist-bin-liferay" depends="dist-bin" description="Prepares all binary distributables for Liferay"> - <!-- TODO implement --> + <mkdir dir="${dist-bin-liferay.dir}"/> + + <!-- deploy --> + <!-- set CATALINA_HOME --> + <!-- TODO call 2x deploy --> + + <!-- copy all webapps --> + <copy todir="${dist-bin-liferay.dir}/webapps"> + <fileset dir="${env.CATALINA_HOME}/webapps" includes="kosmos-portlet/**/*"/> + <fileset dir="${env.CATALINA_HOME}/webapps" includes="kosmos-server/**/*"/> + <fileset dir="${env.CATALINA_HOME}/webapps" includes="slide/**/*"/> + </copy> + + <!-- copy all documents --> + <copy todir="${dist-bin-liferay.dir}"> + <fileset dir="${dist-bin.dir}" includes="docs/**/*"/> + <fileset dir="${dist-bin.dir}" includes="*.*"/> + </copy> + + <!-- pack --> + <zip file="${dist.dir}/${distro-bin-liferay.name}.zip" basedir="${dist.dir}" includes="${distro-bin-liferay.name}/**"/> + <tar destfile="${dist.dir}/${distro-bin-liferay.name}.tar.gz" basedir="${dist.dir}" includes="${distro-bin-liferay.name}/**" compression="gzip" longfile="gnu"/> </target> - </project> |
From: <jbo...@li...> - 2005-12-18 13:55:20
|
Author: aron.gombas Date: 2005-12-18 08:55:10 -0500 (Sun, 18 Dec 2005) New Revision: 1841 Modified: trunk/labs/kosmos/xdocs/others/welcome.txt Log: Support email -> URL change Modified: trunk/labs/kosmos/xdocs/others/welcome.txt =================================================================== --- trunk/labs/kosmos/xdocs/others/welcome.txt 2005-12-18 10:32:26 UTC (rev 1840) +++ trunk/labs/kosmos/xdocs/others/welcome.txt 2005-12-18 13:55:10 UTC (rev 1841) @@ -19,4 +19,4 @@ Free technical support: http://www.jboss.com/index.html?module=bb&op=viewforum&f=225 -Professional support: in...@mi... +Professional support: http://www.midori.hu |
From: <jbo...@li...> - 2005-12-18 10:32:34
|
Author: aron.gombas Date: 2005-12-18 05:32:26 -0500 (Sun, 18 Dec 2005) New Revision: 1840 Modified: trunk/labs/kosmos/build-distro.xml Log: Preconf package built for JBP Modified: trunk/labs/kosmos/build-distro.xml =================================================================== --- trunk/labs/kosmos/build-distro.xml 2005-12-18 10:31:58 UTC (rev 1839) +++ trunk/labs/kosmos/build-distro.xml 2005-12-18 10:32:26 UTC (rev 1840) @@ -10,11 +10,15 @@ <project basedir="." default="dist" name="Kosmos Distro"> <description>Kosmos Distro build-file</description> +<!-- TODO kitakarit es valtozokat hasznal --> + <!-- read basic properties --> + <property environment="env"/> <property file="build/build.properties"/> <property file="build/kosmos-project.properties"/> <property name="distro-bin.name" value="${project.name.short}-${project.version}"/> <property name="distro-src.name" value="${project.name.short}-src-${project.version}"/> + <property name="distro-bin-jboss-portal.name" value="${distro-bin.name}-for-jboss-portal"/> <!-- generated paths --> <property name="src.dir" location="src"/> @@ -29,11 +33,10 @@ <property name="dist-src.dir" location="${dist.dir}/${distro-src.name}"/> <property name="dist-src.docs.api.dir" location="${dist-src.dir}/docs/api"/> + <property name="dist-bin-jboss-portal.dir" location="${dist.dir}/${distro-bin-jboss-portal.name}"/> + <property name="xdocs.dir" location="xdocs"/> <property name="reference.dir" location="${xdocs.dir}/reference"/> - -<!-- TODO create preconfigured package for Gridsphere and JBP?! --> -<!-- TODO install with the deploy scripts? --> <!-- targets --> <target name="init"> @@ -47,14 +50,14 @@ <delete dir="${dist.dir}"/> </target> - <target name="dist" depends="init,clean,dist-bin,dist-src" description="Prepares all distributables"/> + <target name="dist" depends="init,clean,dist-bin,dist-src,dist-bin-exo,dist-bin-gridsphere,dist-bin-jboss-portal,dist-bin-liferay" description="Prepares all distributables"/> <target name="dist-bin" depends="init,clean,manual" description="Prepares all binary distributables"> <!-- prepare subprojects --> <ant antfile="build-portlet.xml" target="dist-bin" inheritall="false"/> <ant antfile="build-server.xml" target="dist-bin" inheritall="false"/> - <!-- collect all files --> + <!-- copy all binaries --> <mkdir dir="${dist-bin.etc.dir}"/> <mkdir dir="${dist-bin.portlet.dir}"/> <mkdir dir="${dist-bin.server.dir}"/> @@ -68,7 +71,7 @@ <fileset dir="dist-bin-server" includes="**/*"/> </copy> <copy todir="${dist-bin.dir}"> - <fileset dir="xdocs/others" includes="**/*"/> + <fileset dir="${xdocs.dir}/others" includes="**/*"/> </copy> <!-- pack --> @@ -77,7 +80,7 @@ </target> <target name="dist-src" depends="init,clean,javadocs" description="Prepares all source distributables"> - <!-- collect all files --> + <!-- copy all sources --> <mkdir dir="${dist-src.dir}"/> <copy todir="${dist-src.dir}"> <fileset dir="." includes="build-*.xml,deploy-*.xml"/> @@ -140,4 +143,42 @@ <arg value="${dist-bin.docs.reference.dir}/pdf/reference-manual.pdf"/> </java> </target> + + <target name="dist-bin-exo" depends="dist-bin" description="Prepares all binary distributables for eXo"> +<!-- TODO implement --> + </target> + + <target name="dist-bin-gridsphere" depends="dist-bin" description="Prepares all binary distributables for Gridsphere"> +<!-- TODO implement --> + </target> + + <target name="dist-bin-jboss-portal" depends="dist-bin" description="Prepares all binary distributables for JBoss Portal"> + <mkdir dir="${dist-bin-jboss-portal.dir}"/> + + <!-- deploy --> + <!-- TODO call 2x deploy --> + + <!-- copy all webapps --> + <mkdir dir="${dist-bin-jboss-portal.dir}/deploy"/> + <copy todir="${dist-bin-jboss-portal.dir}/deploy"> + <fileset dir="${env.JBOSS_HOME}/server/default/deploy" includes="kosmos-portlet.war/**/*"/> + <fileset dir="${env.JBOSS_HOME}/server/default/deploy" includes="kosmos-server.war/**/*"/> + <fileset dir="${env.JBOSS_HOME}/server/default/deploy" includes="slide.war/**/*"/> + </copy> + + <!-- copy all documents --> + <copy todir="${dist-bin-jboss-portal.dir}"> + <fileset dir="${dist-bin.dir}" includes="docs/**/*"/> + <fileset dir="${dist-bin.dir}" includes="*.*"/> + </copy> + + <!-- pack --> + <zip file="${dist.dir}/${distro-bin-jboss-portal.name}.zip" basedir="${dist.dir}" includes="${distro-bin-jboss-portal.name}/**"/> + <tar destfile="${dist.dir}/${distro-bin-jboss-portal.name}.tar.gz" basedir="${dist.dir}" includes="${distro-bin-jboss-portal.name}/**" compression="gzip" longfile="gnu"/> + </target> + + <target name="dist-bin-liferay" depends="dist-bin" description="Prepares all binary distributables for Liferay"> + <!-- TODO implement --> + </target> + </project> |
From: <jbo...@li...> - 2005-12-18 10:32:09
|
Author: aron.gombas Date: 2005-12-18 05:31:58 -0500 (Sun, 18 Dec 2005) New Revision: 1839 Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/AbstractKosmosService.java trunk/labs/kosmos/src/java/hu/midori/kosmos/server/cc/CcServiceImpl.java trunk/labs/kosmos/src/java/hu/midori/kosmos/server/jira/JiraServiceImpl.java trunk/labs/kosmos/src/java/hu/midori/kosmos/server/svn/SvnServiceImpl.java Log: Naming fixed Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/AbstractKosmosService.java =================================================================== --- trunk/labs/kosmos/src/java/hu/midori/kosmos/server/AbstractKosmosService.java 2005-12-18 00:30:58 UTC (rev 1838) +++ trunk/labs/kosmos/src/java/hu/midori/kosmos/server/AbstractKosmosService.java 2005-12-18 10:31:58 UTC (rev 1839) @@ -129,7 +129,7 @@ * Must be called before the first file gets stored. * @see CachedDataStore */ - protected void beginXxx() { + protected void beginStoreSession() { log.debug(String.format("Beginning store session....")); store.begin(); } @@ -138,7 +138,7 @@ * Must be called after the last file got stored. * @see CachedDataStore */ - protected void endXxx() { + protected void endStoreSession() { log.debug(String.format("Ending store session...")); store.end(); } Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/cc/CcServiceImpl.java =================================================================== --- trunk/labs/kosmos/src/java/hu/midori/kosmos/server/cc/CcServiceImpl.java 2005-12-18 00:30:58 UTC (rev 1838) +++ trunk/labs/kosmos/src/java/hu/midori/kosmos/server/cc/CcServiceImpl.java 2005-12-18 10:31:58 UTC (rev 1839) @@ -76,7 +76,7 @@ String url = key.toString(); List<CcProject> projects = new ArrayList<CcProject>(); - beginXxx(); + beginStoreSession(); try { Document dom = ScrapingUtils.downloadHtmlDom(new URL(url)); @@ -160,7 +160,7 @@ log.error("Unable to scrape", ex); } - endXxx(); + endStoreSession(); return projects; } Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/jira/JiraServiceImpl.java =================================================================== --- trunk/labs/kosmos/src/java/hu/midori/kosmos/server/jira/JiraServiceImpl.java 2005-12-18 00:30:58 UTC (rev 1838) +++ trunk/labs/kosmos/src/java/hu/midori/kosmos/server/jira/JiraServiceImpl.java 2005-12-18 10:31:58 UTC (rev 1839) @@ -73,7 +73,7 @@ String url = key.toString(); List<JiraProject> projects = new ArrayList<JiraProject>(); - beginXxx(); + beginStoreSession(); try { // download database info @@ -274,7 +274,7 @@ log.error("Unable to scrape", ex); } - endXxx(); + endStoreSession(); return projects; } Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/svn/SvnServiceImpl.java =================================================================== --- trunk/labs/kosmos/src/java/hu/midori/kosmos/server/svn/SvnServiceImpl.java 2005-12-18 00:30:58 UTC (rev 1838) +++ trunk/labs/kosmos/src/java/hu/midori/kosmos/server/svn/SvnServiceImpl.java 2005-12-18 10:31:58 UTC (rev 1839) @@ -102,7 +102,7 @@ String url = key.toString(); List<SvnRepository> repositories = new ArrayList<SvnRepository>(); - beginXxx(); + beginStoreSession(); try { // get repository info @@ -129,7 +129,7 @@ log.error("Unable to process the SVN repo", ex); } - endXxx(); + endStoreSession(); return repositories; } @@ -228,7 +228,7 @@ SvnRepositoryLogStats stats = new SvnRepositoryLogStats(); log.info(String.format("Analyzing log of \"%s\" repository...", repository.getLocation().toString())); - Collection<SVNLogEntry> logEntries = (Collection<SVNLogEntry>)repository.log(new String[] {""}, null, 0, repository.getLatestRevision(), true, true);// TODO set the target path here + Collection<SVNLogEntry> logEntries = (Collection<SVNLogEntry>)repository.log(new String[] {""}, null, 0, repository.getLatestRevision(), true, false); log.info(String.format("%d log-entries received.", logEntries.size())); // analyze @@ -288,15 +288,17 @@ char type = logEntryPath.getType(); // skip copied branches - if(logEntryPath.getCopyPath() != null)// TODO can this fix the physFileNo+phyDirNo != countedDirEntryNo problem? - continue; + //if(logEntryPath.getCopyPath() != null) + // continue; - // TODO merge this method with the 2adder stuff + // update repo entry counters + int repoEntryAdder = 0; switch(type) { - case 'A': addedFiles++; break; // 'add' - case 'D': deletedFiles++; break;// 'delete' + case 'A': addedFiles++; repoEntryAdder = 1; break; // 'add' + case 'D': deletedFiles++; repoEntryAdder = -1; break; // 'delete' case 'M': modifiedFiles++; break; // 'modify' case 'R': replacedFiles++; break; // 'replace' + default: throw new IllegalArgumentException(String.format("Unknown commit type '%c'", type)); } // count commits-per-file @@ -306,9 +308,9 @@ // count files-per-week TimeSeriesDataItem repoEntriesPerCurrentWeek = stats.repoEntriesPerWeek.getDataItem(commitWeek); if(repoEntriesPerCurrentWeek != null) - stats.repoEntriesPerWeek.addOrUpdate(commitWeek, repoEntriesPerCurrentWeek.getValue().intValue() + commitTypeToAdder(type)); + stats.repoEntriesPerWeek.addOrUpdate(commitWeek, repoEntriesPerCurrentWeek.getValue().intValue() + repoEntryAdder); else - stats.repoEntriesPerWeek.add(commitWeek, commitTypeToAdder(type)); + stats.repoEntriesPerWeek.add(commitWeek, repoEntryAdder); } } @@ -326,17 +328,6 @@ return stats; } - /** Returns the Subversion commit types as adders in file count ('A' meaning 'add' will return +1). */ - protected int commitTypeToAdder(char type) { - switch(type) { - case 'A': return 1; // 'add' - case 'D': return -1; // 'delete' - case 'M': return 0; // 'modify' - case 'R': return 0; // 'replace' - default: throw new IllegalArgumentException(String.format("Unknown commit type '%c'", type)); - } - } - /** Wraps the stats retrieved from the log of a SVN repository. */ private class SvnRepositoryContentStats { public int dirs; |
From: <jbo...@li...> - 2005-12-18 00:31:03
|
Author: unibrew Date: 2005-12-17 19:30:58 -0500 (Sat, 17 Dec 2005) New Revision: 1838 Modified: trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/Poll.java trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/PollDescriptor.java trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/PollTools.java trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/PollsDescriptor.java trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/PollsWatcher.java Log: [JBLAB-407] Poll's source update. Modified: trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/Poll.java =================================================================== --- trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/Poll.java 2005-12-17 18:31:51 UTC (rev 1837) +++ trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/Poll.java 2005-12-18 00:30:58 UTC (rev 1838) @@ -1,6 +1,7 @@ package org.jboss.forge.common.projects; -import java.util.Hashtable; +import java.util.Collections; +import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; @@ -11,7 +12,7 @@ private Map<String,Integer> votes; public Poll (Set<String>answers,String question, String pollId) { - votes = new Hashtable<String,Integer>(answers.size()); + votes = Collections.synchronizedMap(new LinkedHashMap<String,Integer>(answers.size())); for (String answer : answers){ votes.put(answer,new Integer(0)); } @@ -21,7 +22,7 @@ public Poll (Map<String,Integer>votes,String question, String pollId) { this.votes = votes; - if (votes==null) this.votes = new Hashtable<String,Integer>(); + if (votes==null) this.votes = Collections.synchronizedMap(new LinkedHashMap<String,Integer>()); this.question = question; this.pollId = pollId; } Modified: trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/PollDescriptor.java =================================================================== --- trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/PollDescriptor.java 2005-12-17 18:31:51 UTC (rev 1837) +++ trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/PollDescriptor.java 2005-12-18 00:30:58 UTC (rev 1838) @@ -25,10 +25,10 @@ import java.io.IOException; import java.io.InputStream; -import java.util.HashSet; +import java.util.Collections; +import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; -import java.util.Random; import java.util.Set; import org.apache.xerces.parsers.DOMParser; @@ -80,7 +80,7 @@ n = nodes.item(i); if (n.getNodeType() == Node.ELEMENT_NODE) { String tempQuestion = null; - Set<String> tempAnswers = new HashSet<String>(); + Set<String> tempAnswers = Collections.synchronizedSet(new LinkedHashSet<String>()); System.out.println("[POLLSDESCRIPTOR] IN POLLS"); if (n.getNodeName().equals(POLL)) { System.out.println("[POLLSDESCRIPTOR] IN POLL"); Modified: trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/PollTools.java =================================================================== --- trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/PollTools.java 2005-12-17 18:31:51 UTC (rev 1837) +++ trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/PollTools.java 2005-12-18 00:30:58 UTC (rev 1838) @@ -416,6 +416,7 @@ poll.put("question",pollObj.getQuestion()); poll.put("actionUrl",response.createActionURL().toString()); poll.put("pollId",pollObj.getPollId()); + poll.put("project",projectId); for (String answer : pollObj.getAnswers()) { DelegateContext answerCtx = poll.next("answer"); Modified: trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/PollsDescriptor.java =================================================================== --- trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/PollsDescriptor.java 2005-12-17 18:31:51 UTC (rev 1837) +++ trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/PollsDescriptor.java 2005-12-18 00:30:58 UTC (rev 1838) @@ -26,7 +26,9 @@ import java.io.File; import java.io.InputStream; import java.util.ArrayList; +import java.util.Collections; import java.util.Hashtable; +import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -275,7 +277,7 @@ } } - removePollsFromVoting(pollsToDelete); + removePollsFromVoting(pollsToDelete,projectId); addPollsForVoting (descPolls,projectId); @@ -317,11 +319,11 @@ * @param pollsToDelete * List<String> of polls which should be removed. */ - private synchronized void removePollsFromVoting (List<Poll> pollsToDelete) { + private synchronized void removePollsFromVoting (List<Poll> pollsToDelete,final String projectId) { // Removing polls which shouldn't be tracked any more. for (Poll poll:pollsToDelete) { database.removePollDataFile(poll.getPollId()); - polls.remove(poll); + polls.get(projectId).remove(poll); } } @@ -391,6 +393,7 @@ org.jboss.shotoku.Node xmlFile = contentManager.getNode(pathToPollsXml); xmlFile.setContent(xmlString); xmlFile.save ("[Polls] Main xml descriptor file update."); + changeStatus=false; System.out.println ("AFTER SYNCHRONIZING MAIN XML FILE"); } catch (Exception e) { e.printStackTrace(); @@ -544,7 +547,7 @@ for (int j=0;j< pollNodes.getLength() ; j++) { pollNode = pollNodes.item(j); String tempQuestion = null; - Map<String,Integer> answerVotes = new Hashtable<String,Integer>(); + Map<String,Integer> answerVotes = Collections.synchronizedMap(new LinkedHashMap<String,Integer>()); String tempPollId = null; if (pollNode.getNodeType()== Node.ELEMENT_NODE && pollNode.getNodeName().equals(POLL)) { NodeList properties = pollNode.getChildNodes(); Modified: trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/PollsWatcher.java =================================================================== --- trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/PollsWatcher.java 2005-12-17 18:31:51 UTC (rev 1837) +++ trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/PollsWatcher.java 2005-12-18 00:30:58 UTC (rev 1838) @@ -23,7 +23,6 @@ package org.jboss.forge.common.projects; -import java.util.Collection; import java.util.Set; import org.jboss.forge.common.service.NodeWatcher; |
From: <jbo...@li...> - 2005-12-17 18:31:57
|
Author: aron.gombas Date: 2005-12-17 13:31:51 -0500 (Sat, 17 Dec 2005) New Revision: 1837 Modified: trunk/labs/kosmos/web-portlet/pages/svn_monitoring_activity_details.jsp Log: Standard SVN commit type chars used in the output Modified: trunk/labs/kosmos/web-portlet/pages/svn_monitoring_activity_details.jsp =================================================================== --- trunk/labs/kosmos/web-portlet/pages/svn_monitoring_activity_details.jsp 2005-12-17 17:40:41 UTC (rev 1836) +++ trunk/labs/kosmos/web-portlet/pages/svn_monitoring_activity_details.jsp 2005-12-17 18:31:51 UTC (rev 1837) @@ -47,7 +47,7 @@ <tr id="row-<portlet:namespace/>-0-<c:out value="${status.index}"/>" style="display: none" class="portlet-section-alternate"> </c:otherwise> </c:choose> - <td><c:out value="${commit.message}"/><br/>(+<c:out value="${commit.addedFiles}"/> -<c:out value="${commit.deletedFiles}"/> ~<c:out value="${commit.modifiedFiles}"/> /<c:out value="${commit.replacedFiles}"/>)</td> + <td><c:out value="${commit.message}"/><br/>(A<c:out value="${commit.addedFiles}"/> D<c:out value="${commit.deletedFiles}"/> U<c:out value="${commit.modifiedFiles}"/> R<c:out value="${commit.replacedFiles}"/>)</td> <td><c:out value="${commit.author}"/></td> <td> <c:if test="${commit.ageInDays == 0}"><span class="portlet-msg-alert"></c:if> |
From: <jbo...@li...> - 2005-12-17 17:40:50
|
Author: adamw Date: 2005-12-17 12:40:41 -0500 (Sat, 17 Dec 2005) New Revision: 1836 Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/service/SvnRepository.java Log: http://jira.jboss.com/jira/browse/JBSHOTOKU-37 : wc update optimization Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/service/SvnRepository.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/service/SvnRepository.java 2005-12-17 17:03:21 UTC (rev 1835) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/service/SvnRepository.java 2005-12-17 17:40:41 UTC (rev 1836) @@ -60,6 +60,12 @@ private Set<String> frozenModifiedTrees; private Set<String> frozenDeletedResources; + /** + * <code>lastRevision</code> - last revision to which the wc was updated. + * Used to prevent unnecessary updates if the revision hasn't changed. + */ + private long lastRevision; + private Object synchronizer; public SvnRepository(String username, String password, @@ -78,6 +84,8 @@ log.warn("Error while creating SVNRepoistory.", e); } + lastRevision = -1; + this.url = url; wc = new File(localpath); @@ -136,6 +144,17 @@ */ private synchronized void update(boolean tryCheckout, boolean firstTime) { /* + * Checking if there is any need for updating the working copy. + */ + try { + if (lastRevision == repository.getLatestRevision()) { + return; + } + } catch (SVNException e1) { + // Trying to continue ... + } + + /* * Freezing all entries in the modified/ deleted sets. After update, * these sets will be cleaned, because all changes that they stored * information about will be reflected in the WC. But any files that @@ -168,7 +187,7 @@ * probably the wc hasn't been checked out yet. That's why * we try to do a check out in case of an error. */ - updateClient.doUpdate(wc, SVNRevision.HEAD, + lastRevision = updateClient.doUpdate(wc, SVNRevision.HEAD, true); } catch (SVNException e) { if (tryCheckout) { |
From: <jbo...@li...> - 2005-12-17 17:03:37
|
Author: adamw Date: 2005-12-17 12:03:21 -0500 (Sat, 17 Dec 2005) New Revision: 1835 Removed: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/test/CommitTest.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/test/DirectoryTest.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/test/PropertiesTest.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/test/StandaloneTest.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/test/StaticTest.java Modified: trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/Node.java trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/Resource.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/AbstractSvnDirectory.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/AbstractSvnNode.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/AbstractSvnResource.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnHistoricNode.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnResource.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnResourceProxy.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/operations/ModifyDirectoryOperation.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/operations/ModifyFileOperation.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/test/ trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/PropertiesTest.java Log: http://jira.jboss.com/jira/browse/JBSHOTOKU-45 : done Modified: trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/Node.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/Node.java 2005-12-17 16:35:30 UTC (rev 1834) +++ trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/Node.java 2005-12-17 17:03:21 UTC (rev 1835) @@ -71,7 +71,10 @@ /** * Gets an output stream for writing data to the node. The stream will be * automatically closed upon invocation of any of the getContent...() - * methods, getLenght() or the save() method. + * methods, getLenght() or the save() method. Using this method for setting + * content instead of the other ones, is an indication to the + * implementation that the content will be large, so a temporary file could + * be used instead of a in-memory object. * * @return An output stream for writing data to the node. */ Modified: trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/Resource.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/Resource.java 2005-12-17 16:35:30 UTC (rev 1834) +++ trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/Resource.java 2005-12-17 17:03:21 UTC (rev 1835) @@ -83,6 +83,15 @@ * @throws RepositoryException */ public String getProperty(String propertyName) throws RepositoryException; + + /** + * Deletes the the given property. + * + * @param propertyName + * Name of the property to delete. + * @throws RepositoryException + */ + public void deleteProperty(String propertyName) throws RepositoryException; /** * Sets the value of the given property. Only after saving this change will be Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/AbstractSvnDirectory.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/AbstractSvnDirectory.java 2005-12-17 16:35:30 UTC (rev 1834) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/AbstractSvnDirectory.java 2005-12-17 17:03:21 UTC (rev 1835) @@ -54,7 +54,7 @@ public void addOperations(Collection<ResourceOperation> ops) { if (checkForChanges()) { ops.add(new ModifyDirectoryOperation(getId(), getFullPath(), - getModifiedProperties())); + getModifiedProperties(), getDeletedProperties())); } } Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/AbstractSvnNode.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/AbstractSvnNode.java 2005-12-17 16:35:30 UTC (rev 1834) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/AbstractSvnNode.java 2005-12-17 17:03:21 UTC (rev 1835) @@ -85,7 +85,8 @@ if (checkForChanges()) { ops.add(new ModifyFileOperation(getId(), getFullPath(), content.getChanged() ? getLength() : -1, - getModifiedProperties(), getNodeContent())); + getModifiedProperties(), getDeletedProperties(), + getNodeContent())); } } Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/AbstractSvnResource.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/AbstractSvnResource.java 2005-12-17 16:35:30 UTC (rev 1834) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/AbstractSvnResource.java 2005-12-17 17:03:21 UTC (rev 1835) @@ -54,6 +54,10 @@ * modified for this resource and have to be written upon save. */ private Map<String, String> modifiedProperties; + /** + * <code>deletedProperties</code> - a set of names of deleted properties. + */ + private Set<String> deletedProperties; private SvnService service; @@ -75,6 +79,7 @@ fullName = pathParams[2]; modifiedProperties = new HashMap<String, String>(); + deletedProperties = new HashSet<String>(); service = SvnTools.getService(); } @@ -95,7 +100,7 @@ * @return True if there are any changes in properties. */ public boolean checkForChanges() { - return modifiedProperties.size() > 0; + return modifiedProperties.size() > 0 || deletedProperties.size() > 0; } public void notifySaved() { @@ -118,8 +123,14 @@ return modifiedProperties; } - public void setModifiedProperties(Map<String, String> properties) { + public Set<String> getDeletedProperties() { + return deletedProperties; + } + + public void setModifiedProperties(Map<String, String> properties, + Set<String> deletedProperties) { modifiedProperties = properties; + this.deletedProperties = deletedProperties; } public boolean switchable() { @@ -175,6 +186,10 @@ return modifiedProperties.get(name); } + if (deletedProperties.contains(name)) { + return null; + } + return getPropertyInternal(name); } @@ -182,14 +197,31 @@ Map<String, String> ret = getPropertiesInternal(); ret.putAll(modifiedProperties); + for (String deletedPropertyName : deletedProperties) { + ret.remove(deletedPropertyName); + } return ret; } public void setProperty(String name, String value) { - modifiedProperties.put(name, value); + if (value == null) { + /* + * Checking if the user doesn't try to delete the property using + * this method. + */ + deleteProperty(name); + } else { + deletedProperties.remove(name); + modifiedProperties.put(name, value); + } } + public void deleteProperty(String name) { + deletedProperties.add(name); + modifiedProperties.remove(name); + } + public String getName() { return name; } Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnHistoricNode.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnHistoricNode.java 2005-12-17 16:35:30 UTC (rev 1834) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnHistoricNode.java 2005-12-17 17:03:21 UTC (rev 1835) @@ -177,6 +177,11 @@ } @Override + public void deleteProperty(String name) { + throw new NodeReadOnly(); + } + + @Override public void moveTo(Directory d, String logMessage) { throw new NodeReadOnly(); } Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnResource.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnResource.java 2005-12-17 16:35:30 UTC (rev 1834) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnResource.java 2005-12-17 17:03:21 UTC (rev 1835) @@ -23,6 +23,7 @@ import java.util.Collection; import java.util.Map; +import java.util.Set; import org.jboss.shotoku.Resource; import org.jboss.shotoku.exceptions.DeleteException; @@ -47,5 +48,7 @@ public SvnContentManager getSvnCm(); public Map<String, String> getModifiedProperties(); - public void setModifiedProperties(Map<String, String> properties); + public Set<String> getDeletedProperties(); + public void setModifiedProperties(Map<String, String> properties, + Set<String> deletedProperties); } Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnResourceProxy.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnResourceProxy.java 2005-12-17 16:35:30 UTC (rev 1834) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnResourceProxy.java 2005-12-17 17:03:21 UTC (rev 1835) @@ -23,6 +23,7 @@ import java.util.Collection; import java.util.Map; +import java.util.Set; import org.jboss.shotoku.Directory; import org.jboss.shotoku.exceptions.CopyException; @@ -90,7 +91,8 @@ if (oldResource != null) { currentResource.setModifiedProperties( - oldResource.getModifiedProperties()); + oldResource.getModifiedProperties(), + oldResource.getDeletedProperties()); } isRepoResource = false; @@ -102,7 +104,8 @@ if (oldResource != null) { currentResource.setModifiedProperties( - oldResource.getModifiedProperties()); + oldResource.getModifiedProperties(), + oldResource.getDeletedProperties()); } isRepoResource = true; @@ -186,10 +189,15 @@ return currentResource.getModifiedProperties(); } - public void setModifiedProperties(Map<String, String> properties) { - currentResource.setModifiedProperties(properties); + public Set<String> getDeletedProperties() { + return currentResource.getDeletedProperties(); } + public void setModifiedProperties(Map<String, String> properties, + Set<String> deletedProperties) { + currentResource.setModifiedProperties(properties, deletedProperties); + } + public void notifySaved() { // First notifying about save .. currentResource.notifySaved(); @@ -252,6 +260,11 @@ public void setProperty(String name, String value) { currentResource.setProperty(name, value); } + + public void deleteProperty(String name) { + checkSwitch(); + currentResource.deleteProperty(name); + } public Map<String, String> getProperties() throws RepositoryException { checkSwitch(); Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/operations/ModifyDirectoryOperation.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/operations/ModifyDirectoryOperation.java 2005-12-17 16:35:30 UTC (rev 1834) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/operations/ModifyDirectoryOperation.java 2005-12-17 17:03:21 UTC (rev 1835) @@ -22,6 +22,7 @@ package org.jboss.shotoku.svn.operations; import java.util.Map; +import java.util.Set; import org.jboss.shotoku.svn.SvnService; import org.jboss.shotoku.tools.Tools; @@ -33,12 +34,14 @@ */ public class ModifyDirectoryOperation extends ResourceOperation { private Map<String, String> properties; + private Set<String> deletedProperties; public ModifyDirectoryOperation(String id, String path, - Map<String, String> properties) { + Map<String, String> properties, Set<String> deletedProperties) { super(id, path, OpCode.MODIFY_DIRECTORY); this.properties = properties; + this.deletedProperties = deletedProperties; } public void execute(PathsStack stack) throws SVNException { @@ -46,8 +49,13 @@ ISVNEditor editor = stack.getEditor(); - for (String key : properties.keySet()) + for (String key : properties.keySet()) { editor.changeDirProperty(key, properties.get(key)); + } + + for (String key : deletedProperties) { + editor.changeDirProperty(key, null); + } } public void addModifiedPaths(SvnService service) { Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/operations/ModifyFileOperation.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/operations/ModifyFileOperation.java 2005-12-17 16:35:30 UTC (rev 1834) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/operations/ModifyFileOperation.java 2005-12-17 17:03:21 UTC (rev 1835) @@ -24,6 +24,7 @@ import java.io.IOException; import java.io.OutputStream; import java.util.Map; +import java.util.Set; import org.jboss.shotoku.exceptions.RepositoryException; import org.jboss.shotoku.svn.SvnService; @@ -40,14 +41,17 @@ public class ModifyFileOperation extends ResourceOperation { private long contentLength; private Map<String, String> properties; + private Set<String> deletedProperties; private NodeContent content; public ModifyFileOperation(String id, String path, long contentLength, - Map<String, String> properties, NodeContent content) { + Map<String, String> properties, Set<String> deletedProperties, + NodeContent content) { super(id, path, OpCode.MODIFY_FILE); this.contentLength = contentLength; this.properties = properties; + this.deletedProperties = deletedProperties; this.content = content; } @@ -60,9 +64,14 @@ stack.addPath(path, true); } - for (String key : properties.keySet()) + for (String key : properties.keySet()) { editor.changeFileProperty(path, key, properties.get(key)); + } + for (String key : deletedProperties) { + editor.changeFileProperty(path, key, null); + } + if (contentLength != -1) { editor.applyTextDelta(path, null); SVNDiffWindow diffWindow = SVNDiffWindowBuilder Property changes on: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/test ___________________________________________________________________ Name: svn:ignore + HomeTest.java Deleted: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/test/CommitTest.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/test/CommitTest.java 2005-12-17 16:35:30 UTC (rev 1834) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/test/CommitTest.java 2005-12-17 17:03:21 UTC (rev 1835) @@ -1,154 +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.shotoku.test; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.HashMap; -import java.util.Map; - -import org.tmatesoft.svn.core.SVNCommitInfo; -import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager; -import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory; -import org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryFactoryImpl; -import org.tmatesoft.svn.core.io.ISVNEditor; -import org.tmatesoft.svn.core.io.ISVNWorkspaceMediator; -import org.tmatesoft.svn.core.io.SVNRepository; -import org.tmatesoft.svn.core.io.SVNRepositoryFactory; -import org.tmatesoft.svn.core.wc.SVNWCUtil; - -public class CommitTest { - public static void main(String[] argv) throws Exception { - DAVRepositoryFactory.setup(); - SVNRepositoryFactoryImpl.setup(); - - SVNRepository repository = null; - repository = SVNRepositoryFactory.create(SVNURL.parseURIEncoded( - "https://cms.labs.jboss.com/trunk/forge/portal-content/shotoku-test")); - ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager( - "jbf...@jb...", "rO@B5oPfff"); - repository.setAuthenticationManager(authManager); - - long latestRevision = -1; - latestRevision = repository.getLatestRevision(); - System.out.println("Repository latest revision (before committing): " - + latestRevision); - System.out.println(""); - - ISVNEditor editor = repository.getCommitEditor("zzz", new WorkspaceMediator()); - - editor.openRoot(-1); - editor.openDir("/dir1", -1); - editor.addDir("/dircpy", "dir1/dir3", latestRevision); - - editor.closeDir(); - editor.closeDir(); - editor.closeDir(); - printCommitInfo(editor.closeEdit()); - - /*editor.addFile(filePath, null, -1); - editor.applyTextDelta(filePath, null); - long deltaLength = data.length; - SVNDiffWindow diffWindow = SVNDiffWindowBuilder - .createReplacementDiffWindow(deltaLength); - OutputStream os = editor.textDeltaChunk(filePath, diffWindow); - for (int i = 0; i < deltaLength; i++) { - os.write(data[i]); - } - if (os != null) { - try { - os.close(); - } catch (IOException ioeInternal) { - // - } - } - editor.textDeltaEnd(filePath); - editor.closeFile(filePath, null);*/ - } - - private static void printCommitInfo(SVNCommitInfo commitInfo) { - System.out.println("The last author:" + commitInfo.getAuthor()); - System.out.println("Date:" + commitInfo.getDate().toString()); - System.out.println("Committed to revision " + commitInfo.getNewRevision()); - System.out.println(""); - } -} - -class WorkspaceMediator implements - ISVNWorkspaceMediator { - private Map myTmpFiles = new HashMap(); - - public String getWorkspaceProperty(String path, String name) - throws SVNException { - return null; - } - - public void setWorkspaceProperty(String path, String name, String value) - throws SVNException { - } - - /* - * Creates a temporary file delta storage. id will be used as the - * temporary storage identifier. Returns an OutputStream to write the - * delta data into the temporary storage. - */ - @SuppressWarnings("unchecked") - public OutputStream createTemporaryLocation(String path, Object id) - throws IOException { - ByteArrayOutputStream tempStorageOS = new ByteArrayOutputStream(); - myTmpFiles.put(id, tempStorageOS); - return tempStorageOS; - } - - /* - * Returns an InputStream of the temporary file delta storage identified - * by id to read the delta. - */ - public InputStream getTemporaryLocation(Object id) throws IOException { - return new ByteArrayInputStream(((ByteArrayOutputStream)myTmpFiles.get(id)).toByteArray()); - } - - /* - * Gets the length of the delta that was written to the temporary - * storage identified by id. - */ - public long getLength(Object id) throws IOException { - ByteArrayOutputStream tempStorageOS = (ByteArrayOutputStream)myTmpFiles.get(id); - if (tempStorageOS != null) { - return tempStorageOS.size(); - } - return 0; - } - - /* - * Deletes the temporary file delta storage identified by id. - */ - public void deleteTemporaryLocation(Object id) { - myTmpFiles.remove(id); - } -} - Deleted: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/test/DirectoryTest.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/test/DirectoryTest.java 2005-12-17 16:35:30 UTC (rev 1834) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/test/DirectoryTest.java 2005-12-17 17:03:21 UTC (rev 1835) @@ -1,76 +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.shotoku.test; - -import java.io.File; - -import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory; -import org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryFactoryImpl; -import org.tmatesoft.svn.core.wc.ISVNOptions; -import org.tmatesoft.svn.core.wc.SVNClientManager; -import org.tmatesoft.svn.core.wc.SVNWCUtil; - -/** - * @author Adam Warski (ad...@as...) - * @author Damon Sicore (da...@si...) - */ -public class DirectoryTest { - SVNClientManager clientManager; - - public void test() throws Exception { - DAVRepositoryFactory.setup(); - SVNRepositoryFactoryImpl.setup(); - - File dir = new File("/home/adamw/jboss/content/trunk/forge/portal-content/shotoku-test/inject-test-dir"); - dir.mkdir(); - - File file = new File("/home/adamw/jboss/content/trunk/forge/portal-content/shotoku-test/inject-test-node"); - file.createNewFile(); - - ISVNOptions options = SVNWCUtil.createDefaultOptions(true); - clientManager = - SVNClientManager.newInstance(options, "jbf...@jb...", "rO@B5oPfff"); - - try { - clientManager.getWCClient().doAdd(file, true, false, false, false); - clientManager.getCommitClient().doCommit(new File[] { file }, false, "", true, false); - - clientManager.getWCClient().doAdd(dir, true, false, false, false); - clientManager.getCommitClient().doCommit(new File[] { dir }, false, "", true, false); - } finally { - /* CLEANUP */ - try { - clientManager.getWCClient().doDelete(dir, true, false); - clientManager.getCommitClient().doCommit(new File[] { dir }, false, "", true, false); - } catch (Exception e) { } - - try { - clientManager.getWCClient().doDelete(file, true, false); - clientManager.getCommitClient().doCommit(new File[] { file }, false, "", true, false); - } catch (Exception e) { } - } - } - - public static void main(String[] argv) throws Exception { - new DirectoryTest().test(); - } -} Deleted: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/test/PropertiesTest.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/test/PropertiesTest.java 2005-12-17 16:35:30 UTC (rev 1834) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/test/PropertiesTest.java 2005-12-17 17:03:21 UTC (rev 1835) @@ -1,94 +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.shotoku.test; - -import java.io.File; - -import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory; -import org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryFactoryImpl; -import org.tmatesoft.svn.core.wc.ISVNOptions; -import org.tmatesoft.svn.core.wc.ISVNPropertyHandler; -import org.tmatesoft.svn.core.wc.SVNClientManager; -import org.tmatesoft.svn.core.wc.SVNRevision; -import org.tmatesoft.svn.core.wc.SVNWCUtil; - -/** - * @author Adam Warski (ad...@as...) - * @author Damon Sicore (da...@si...) - */ -public class PropertiesTest { - SVNClientManager clientManager; - File file; - - private void setProperty(String value) throws Exception { - clientManager.getWCClient().doSetProperty(file, "test", value, true, false, ISVNPropertyHandler.NULL); - } - - private void getProperty() throws Exception { - clientManager.getWCClient().doGetProperty(file, "test", SVNRevision.WORKING, SVNRevision.WORKING, - false); - } - - private void commit() throws Exception { - clientManager.getCommitClient().doCommit(new File[] { file }, false, "", true, false); - } - - private void add() throws Exception { - clientManager.getWCClient().doAdd(file, true, false, false, false); - } - - private void delete() throws Exception { - clientManager.getWCClient().doDelete(file, true, false); - } - - public void test() throws Exception { - DAVRepositoryFactory.setup(); - SVNRepositoryFactoryImpl.setup(); - - file = new File("/home/adamw/jboss/content/trunk/forge/portal-content/shotoku-test/prop-test"); - - ISVNOptions options = SVNWCUtil.createDefaultOptions(true); - clientManager = - SVNClientManager.newInstance(options, "jbf...@jb...", "rO@B5oPfff"); - - file.createNewFile(); - add(); - commit(); - setProperty("1"); - commit(); - setProperty("2"); - commit(); - getProperty(); - getProperty(); - getProperty(); - delete(); - commit(); - file.createNewFile(); - Thread.sleep(1000); - System.out.println( - clientManager.getStatusClient().doStatus(file, false).getContentsStatus().getID()); - } - - public static void main(String[] argv) throws Exception { - new PropertiesTest().test(); - } -} Deleted: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/test/StandaloneTest.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/test/StandaloneTest.java 2005-12-17 16:35:30 UTC (rev 1834) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/test/StandaloneTest.java 2005-12-17 17:03:21 UTC (rev 1835) @@ -1,515 +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.shotoku.test; - -import java.util.Arrays; -import java.util.Calendar; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.jboss.shotoku.ContentManager; -import org.jboss.shotoku.Directory; -import org.jboss.shotoku.Node; -import org.jboss.shotoku.Resource; -import org.jboss.shotoku.exceptions.DeleteException; -import org.jboss.shotoku.exceptions.RepositoryException; -import org.jboss.shotoku.exceptions.ResourceAlreadyExists; -import org.jboss.shotoku.exceptions.ResourceDoesNotExist; -import org.jboss.shotoku.exceptions.SaveException; -import org.tmatesoft.svn.core.ISVNLogEntryHandler; -import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.SVNLogEntry; -import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager; -import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory; -import org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryFactoryImpl; -import org.tmatesoft.svn.core.io.SVNRepository; -import org.tmatesoft.svn.core.io.SVNRepositoryFactory; -import org.tmatesoft.svn.core.wc.SVNWCUtil; - -public class StandaloneTest { - public static void testRepo() throws SVNException { - DAVRepositoryFactory.setup(); - SVNRepositoryFactoryImpl.setup(); - - SVNRepository repository = SVNRepositoryFactory.create(SVNURL.parseURIEncoded( - "https://cms.labs.jboss.com/trunk/forge/portal-content")); - - ISVNAuthenticationManager authManager = - SVNWCUtil.createDefaultAuthenticationManager("jbf...@jb...", - "rO@B5oPfff"); - repository.setAuthenticationManager(authManager); - - repository.log(new String[] { "shotoku-test" }, - 22421, 0, false, false, 1, - new ISVNLogEntryHandler() { - public void handleLogEntry(SVNLogEntry entry) { - System.out.println("A"); - } - }); - } - - public static void testCm() throws RepositoryException, ResourceDoesNotExist, - ResourceAlreadyExists, SaveException { - ContentManager cm = ContentManager.getContentManager("shotoku-test"); - //Directory d = cm.getRootDirectory(); - Set<Resource> toSave = new HashSet<Resource>(); - /*for (Directory c : d.getDirectories()) { - System.out.println(c.getName()); - } - - for (Node n : d.getNodes().toList()) { - System.out.println(n.getFullName()); - }*/ - //System.out.println(cm.getRootDirectory().getNode("history-test.txt").getContent()); - /*Node nn = cm.getRootDirectory().newNode("nowy_node"); - nn.setContent("z\n"); - Node nn2 = cm.getRootDirectory().newNode("nowy_node2"); - nn2.setContent("z2\n"); - - - toSave.add(nn); - toSave.add(nn2); - cm.save(toSave, "zzz");*/ - //cm.getNode("nowy_node").delete(); - //cm.getNode("nowy_node2").delete(); - - Directory nd = cm.getRootDirectory().newDirectory("nowy_kat"); - Node nn3 = nd.newNode("nowy_node3"); - - toSave.add(nd); - toSave.add(nn3); - - cm.save(toSave, "aaa"); - } - - public static void simpleDirTest() throws DeleteException, RepositoryException, ResourceAlreadyExists, SaveException { - ContentManager cm = ContentManager.getContentManager("shotoku-test"); - - try { - Directory newDir = cm.getRootDirectory().newDirectory("new-dir-test"); - newDir.save("new-dir-test"); - Node newNode = newDir.newNode("new-node"); - newNode.save("new-node"); - } finally { - try { - Directory newDir2 = cm.getDirectory("new-dir-test"); - newDir2.delete(); - } catch (ResourceDoesNotExist e) { - // If it does not exist, all the better, no deleting :). - } - } - } - - private final static String TEST_DIR1 = "parent-test-1"; - private final static String TEST_DIR2 = "parent-test-2"; - private final static String TEST_DIR3 = "parent-test-3"; - - public static void testParent() throws Exception { - ContentManager cm = ContentManager.getContentManager("shotoku-test"); - try { - // First creating a simple directory structure. - Directory new1 = cm.getRootDirectory().newDirectory(TEST_DIR1); - new1.save(TEST_DIR1); - - Directory new2 = new1.newDirectory(TEST_DIR2); - new2.save(TEST_DIR2); - - Directory new3 = new2.newDirectory(TEST_DIR3); - new3.save(TEST_DIR3); - - // Now, having this structure, testing the parents. - - // This should be "identical" to new2. - Directory parentNew3 = new3.getParent(); - - // This should be "identical" to new1. - Directory parentNew2 = new2.getParent(); - - // This should be the root directory. - Directory parentNew1 = new1.getParent(); - - // Checking names. - System.out.println(parentNew3.getName().equals(new2.getName())); - System.out.println(parentNew2.getName().equals(new1.getName())); - System.out.println(parentNew1.getName().equals(cm.getRootDirectory().getName())); - - // The parents should have appropriate children - trying to - // get them. - parentNew1.getDirectory(TEST_DIR1); - parentNew2.getDirectory(TEST_DIR2); - parentNew3.getDirectory(TEST_DIR3); - } finally { - try { - cm.getDirectory(TEST_DIR1).delete(); - } catch (Exception e) { - - } - } - } - - private static ContentManager cm; - //private final static String TEST_FILE = "add-delete-test-1"; - private static void checkTestFileNotExists() { - try { - cm.getNode(TEST_FILE); - - // An exception should be thrown. - throw new RuntimeException("ZZZZ"); - } catch (ResourceDoesNotExist e) { - // Getting here means everything is ok. - } - } - public static void addDeleteTest() throws Exception { - - try { - Node n = cm.getRootDirectory().newNode(TEST_FILE); - - checkTestFileNotExists(); - - n.save(TEST_FILE); - - // The file should exist now. - try { - cm.getNode(TEST_FILE); - } catch (ResourceDoesNotExist e) { - throw e; - } - - // Waiting for an update for 20 seconds ... - try { - Thread.sleep(1000 * 20); - } catch (InterruptedException e) { - throw e; - } - - // The file should still exist. - try { - cm.getNode(TEST_FILE); - } catch (ResourceDoesNotExist e) { - throw e; - } - - n.delete(); - - checkTestFileNotExists(); - } finally { - try { - cm.getNode(TEST_FILE).delete(); - } catch (ResourceDoesNotExist e) { - // If it does not exist - doing nothing. - } - } - } - - private final static String TEST_FILE = "content-saving-test-1"; - private final static String TEST_CONTENT_3 = "c"; - - private static void assertNodeContent(Node n, String content) { - System.out.println(content.equals(n.getContent())); - System.out.println(Arrays.equals(content.getBytes(), n.getContentByteArray())); - } - - public static void contentSetTest() throws Exception { - try { - Node n0 = cm.getRootDirectory().newNode(TEST_FILE); - n0.save(TEST_FILE); - - // Getting the test node. - Node n = cm.getNode(TEST_FILE); - - // Modifying the content. - //n.setContent(TEST_CONTENT_3.getBytes()); - n.getOutputStream().write(TEST_CONTENT_3.getBytes()); - n.save(TEST_FILE); - - // Checking if changes are visible. - assertNodeContent(n, TEST_CONTENT_3); - assertNodeContent(cm.getRootDirectory().getNode(TEST_FILE), TEST_CONTENT_3); - } finally { - try { - cm.getNode(TEST_FILE).delete(); - } catch (Throwable e) { - e.printStackTrace(); - System.out.println("Z"); - } - } - } - - public static void addDelDir() throws Exception { - try { - // Creating the directory. - Directory newDir = cm.getRootDirectory().newDirectory("new-dir-test"); - - // Saving the dir - it should be created. - newDir.save("new-dir-test"); - - // Creating some nodes and directories in it. - Node newNode = newDir.newNode("node2"); - newNode.save("node2"); - newNode.setContent("test"); - newNode.save("node2-2"); - - System.out.println(cm.getNode("new-dir-test/node2").getContent()); - } finally { - try { - Directory newDir = cm.getDirectory("new-dir-test"); - newDir.delete(); - } catch (ResourceDoesNotExist e) { - // If it does not exist, all the better, no deleting :). - } - } - } - - //private final static String TEST_DIR = "slash-test-dir"; - private final static String TEST_NESTED_DIR = "a/b/c"; - private final static String TEST_NESTED_NODE = "h/j/k"; - private final static String TEST_CONTENT = "T"; - - public static void testNested() throws Exception { - try { - cm.getRootDirectory().newDirectory(TEST_DIR).save(TEST_DIR); - - ContentManager cm1 = ContentManager.getContentManager("/shotoku-test/"); - cm1.getRootDirectory().getDirectory(TEST_DIR); - - ContentManager cm2 = ContentManager.getContentManager( - "//shotoku-test///" + TEST_DIR + "///"); - cm2.getRootDirectory(); - } finally { - try { - cm.getDirectory(TEST_DIR).delete(); - } catch (ResourceDoesNotExist e) { - - } - } - - try { - cm.getRootDirectory().newDirectory(TEST_DIR).save(TEST_DIR); - - Directory base = cm.getDirectory(TEST_DIR); - base.newDirectory("h").save("h"); - - Node nested = base.newNode(TEST_NESTED_NODE); - System.out.println((TEST_DIR + "/" + TEST_NESTED_NODE).equals(nested.getFullName())); - - nested.setContent(TEST_CONTENT); - nested.save(TEST_NESTED_NODE); - - System.out.println(TEST_CONTENT.equals(base.getDirectory("h"). - getDirectory("j").getNode("k").getContent())); - System.out.println(TEST_CONTENT.equals(base.getNode(TEST_NESTED_NODE).getContent())); - } finally { - try { - cm.getDirectory(TEST_DIR).delete(); - } catch (ResourceDoesNotExist e) { - - } - } - - try { - cm.getRootDirectory().newDirectory(TEST_DIR).save(TEST_DIR); - - Directory base = cm.getDirectory(TEST_DIR); - Directory nested1 = base.newDirectory(TEST_NESTED_DIR); - Node nested2 = base.newNode(TEST_NESTED_NODE); - - System.out.println((TEST_DIR + "/" + TEST_NESTED_DIR).equals(nested1.getFullName())); - System.out.println((TEST_DIR + "/" + TEST_NESTED_NODE).equals(nested2.getFullName())); - - nested1.save(""); - - nested2.setContent(TEST_CONTENT); - nested2.save(""); - - // We should be able to get the directories and node. - base.getDirectory("a").getDirectory("b").getDirectory("c"); - base.getDirectory(TEST_NESTED_DIR); - - System.out.println(TEST_CONTENT.equals(base.getDirectory("h"). - getDirectory("j").getNode("k").getContent())); - System.out.println(TEST_CONTENT.equals(base.getNode(TEST_NESTED_NODE).getContent())); - } finally { - try { - cm.getDirectory(TEST_DIR).delete(); - } catch (ResourceDoesNotExist e) { - - } - } - } - - private final static String TEST_NODE = "inject-test-node"; - private final static String TEST_DIR = "inject-test-dir"; - private final static String TEST_TEXT = "text"; - private final static String TEST_LOG = "log"; - - public static void testInject() throws Exception { - Thread.sleep(1000 * 1); - try { - Node testNode = cm.getRootDirectory().newNode(TEST_NODE); - testNode.setContent(TEST_TEXT); - testNode.save(TEST_LOG); - - Directory testDir = cm.getRootDirectory().newDirectory(TEST_DIR); - testDir.save(TEST_LOG + "2"); - - Thread.sleep(1000 * 20); - - System.out.println(cm.getNode(TEST_NODE).getLogMessage()); - } finally { - try { - cm.getNode(TEST_NODE).delete(); - } catch(ResourceDoesNotExist e) { - - } - - try { - cm.getDirectory(TEST_DIR).delete(); - } catch(ResourceDoesNotExist e) { - - } - } - } - - public static void multiSaveTest() throws Exception { - try { - Directory newDir1 = cm.getRootDirectory().newDirectory(TEST_DIR); - - Directory newDir2 = newDir1.newDirectory("a/b/c"); - Node newNode1 = newDir1.newNode("a/b/d/n1"); - - Directory newDir3 = newDir2.newDirectory("z"); - Node newNode2 = newDir3.newNode("aaa"); - - newNode2.setContent("P"); - - cm.save(newDir1, newDir2, newNode1, newNode2, ""); - - System.out.println("P".equals(cm.getNode(TEST_DIR + "/a/b/c/z/aaa"))); - } finally { - try { - cm.getDirectory(TEST_DIR).delete(); - } catch (ResourceDoesNotExist e) { - // If it does not exist - doing nothing. - } - } - } - - public static void testCopy() throws Exception { - try { - Directory parent = cm.getRootDirectory().newDirectory(TEST_DIR); - Directory dir1 = parent.newDirectory("dir1"); - Directory dir2 = parent.newDirectory("dir2"); - Node n1 = dir1.newNode("node1"); - n1.setContent(TEST_CONTENT); - - cm.save(parent, dir1, dir2, n1, "setup"); - - Directory original = cm.getDirectory(TEST_DIR + "/dir1"); - original.copyTo(cm.getDirectory(TEST_DIR + "/dir2"), "dir3", "copy-dir"); - - System.out.println(TEST_CONTENT.equals(cm.getNode(TEST_DIR + "/dir2/dir3/node1").getContent())); - } finally { - try { - cm.getDirectory(TEST_DIR).delete(); - } catch (ResourceDoesNotExist e) { - - } - } - } - - private static void checkProperties(Node n) { - Map<String, String> props = n.getProperties(); - - System.out.println(props.size()); - } - - public static void propsTest() throws Exception { - try { - Node n0 = cm.getRootDirectory().newNode(TEST_FILE); - n0.save(TEST_FILE); - - Node n = cm.getNode(TEST_FILE); - - /*Random r = new Random(); - for (int i=0; i<3; i++) { - n.setProperty(Integer.toString(r.nextInt() % 3), Integer.toString(r.nextInt() % 2)); - }*/ - n.setProperty("0", "0"); - n.setProperty("1", "2"); - n.save("a"); - - checkProperties(n); - checkProperties(cm.getNode(TEST_FILE)); - - // Waiting for a WC update. - Thread.sleep(1000 * 10); - checkProperties(n); - checkProperties(cm.getNode(TEST_FILE)); - - } finally { - cm.getNode(TEST_FILE).delete(); - } - } - - public static void printMap(Map m) { - for (Object k : m.keySet()) { - System.out.println(k + " : " + m.get(k)); - } - - System.out.println(); - } - - public static void main(String[] argv) throws Exception { - long now = Calendar.getInstance().getTimeInMillis(); - - ContentManager.setup(); - cm = ContentManager.getContentManager("shotoku-test"); - - /*Map<String, String> properties = new HashMap<String, String>(); - OutputStream os = new ByteArrayOutputStream(); - - System.out.println("REV: " + ((SvnContentManager) cm).getRepository().getFile( - "default/polls/database/1289956185", -1, - properties, os)); - - printMap(properties);*/ - - //propsTest(); - //testCopy(); - //multiSaveTest(); - //testInject(); - //testNested(); - //addDelDir(); - //contentSetTest(); - //addDeleteTest(); - //testParent(); - //logMsgTest(); - //simpleDirTest(); - //testModifyContent(); - //testCm(); - //testRepo(); - - System.out.println((Calendar.getInstance().getTimeInMillis() - now) / 1000); - } -} Deleted: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/test/StaticTest.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/test/StaticTest.java 2005-12-17 16:35:30 UTC (rev 1834) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/test/StaticTest.java 2005-12-17 17:03:21 UTC (rev 1835) @@ -1,45 +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.shotoku.test; - -import java.lang.reflect.InvocationTargetException; - -public class StaticTest { - public static void x() { - System.out.println("Z"); - } - - /** - * @param args - * @throws ClassNotFoundException - * @throws NoSuchMethodException - * @throws InvocationTargetException - * @throws IllegalAccessException - * @throws SecurityException - * @throws IllegalArgumentException - */ - public static void main(String[] args) throws IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, ClassNotFoundException { - Class.forName("org.jboss.shotoku.test.StaticTest").getMethod("x", new Class[0]). - invoke(Class.forName("org.jboss.shotoku.test.StaticTest"), new Object[0]); - } - -} Modified: trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/PropertiesTest.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/PropertiesTest.java 2005-12-17 16:35:30 UTC (rev 1834) +++ trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/PropertiesTest.java 2005-12-17 17:03:21 UTC (rev 1835) @@ -118,6 +118,46 @@ checkProperties(cm.getNode(TEST_FILE)); } + public void testPropertyDelete() throws Exception { + Node n = cm.getNode(TEST_FILE); + + n.setProperty("p1", "v1"); + n.setProperty("p2", "v2"); + + n.save(""); + + n.deleteProperty("p2"); + + assertNull(n.getProperty("p2")); + assertTrue("v1".equals(n.getProperty("p1"))); + assertTrue(1 == n.getProperties().size()); + + assertTrue("v1".equals(cm.getNode(TEST_FILE).getProperty("p1"))); + assertTrue("v2".equals(cm.getNode(TEST_FILE).getProperty("p2"))); + assertTrue(2 == cm.getNode(TEST_FILE).getProperties().size()); + + n.save(""); + + assertNull(n.getProperty("p2")); + assertTrue("v1".equals(n.getProperty("p1"))); + assertTrue(1 == n.getProperties().size()); + + assertNull(cm.getNode(TEST_FILE).getProperty("p2")); + assertTrue("v1".equals(cm.getNode(TEST_FILE).getProperty("p1"))); + assertTrue(1 == cm.getNode(TEST_FILE).getProperties().size()); + + // Waiting for a WC update. + Thread.sleep(1000 * 20); + + assertNull(n.getProperty("p2")); + assertTrue("v1".equals(n.getProperty("p1"))); + assertTrue(1 == n.getProperties().size()); + + assertNull(cm.getNode(TEST_FILE).getProperty("p2")); + assertTrue("v1".equals(cm.getNode(TEST_FILE).getProperty("p1"))); + assertTrue(1 == cm.getNode(TEST_FILE).getProperties().size()); + } + @Override protected void tearDown() throws DeleteException, ResourceAlreadyExists, ResourceDoesNotExist { cm.getNode(TEST_FILE).delete(); |
Author: wrzep Date: 2005-12-17 11:35:30 -0500 (Sat, 17 Dec 2005) New Revision: 1834 Added: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Plugin.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Plugins.java Removed: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/Plugin.java Modified: trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/XmlTools.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Column.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Columns.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/StatusDescriptor.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/ScorePlugin.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/StatusPlugin.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/WeightedScorePlugin.java Log: moved plugins handling to separate class (Plugins.java) new node parsing in XmlTools http://jira.jboss.com/jira/browse/JBLAB-415 Pawel Modified: trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/XmlTools.java =================================================================== --- trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/XmlTools.java 2005-12-17 15:21:32 UTC (rev 1833) +++ trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/XmlTools.java 2005-12-17 16:35:30 UTC (rev 1834) @@ -221,6 +221,25 @@ return null; } + + /** + * Gets value of a node that is a child node of the given one and has the + * given name + * + * @param root Node which children are to be searched. + * @param childNodeName Name of the searched node. + * @return A value of child node with the given ame or null, if no such + * node exists. + */ + public static String getChildNodeValue(Node root, String childNodeName) { + Node node = getFirstNodeWithName(root, childNodeName); + + if (node != null) { + return unmarshallText(node); + } + + return null; + } /** * Reads text contained in a tag of the form <tag>text</tag>. Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Column.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Column.java 2005-12-17 15:21:32 UTC (rev 1833) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Column.java 2005-12-17 16:35:30 UTC (rev 1834) @@ -22,7 +22,6 @@ package org.jboss.forge.status; -import org.jboss.forge.status.plugins.Plugin; import org.jboss.portal.common.context.DelegateContext; /** Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Columns.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Columns.java 2005-12-17 15:21:32 UTC (rev 1833) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Columns.java 2005-12-17 16:35:30 UTC (rev 1834) @@ -26,16 +26,14 @@ import java.util.Collection; import java.util.Iterator; import java.util.List; -import java.util.Map; import java.util.Set; import org.jboss.forge.common.XmlTools; import org.jboss.forge.common.projects.Projects; -import org.jboss.forge.common.projects.ProjectsHelper; import org.jboss.forge.common.projects.permissions.NullPermissionsChecker; import org.jboss.forge.common.projects.permissions.PermissionsChecker; -import org.jboss.forge.status.plugins.Plugin; import org.jboss.portal.common.context.DelegateContext; + import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -47,7 +45,7 @@ List<Column> columns; Projects projects; - public Columns(Node pageRoot, Map<String,Plugin> plugins, Projects projects) { + public Columns(Node pageRoot, Plugins plugins, Projects projects) { this.projects = projects; columns = new ArrayList<Column>(); @@ -57,11 +55,9 @@ Node columnNode = columnsList.item(i); if (columnNode.getNodeType() == Node.ELEMENT_NODE) { - Node nameNode = XmlTools.getFirstNodeWithName(columnNode, "name"); - String name = XmlTools.unmarshallText(nameNode); + String name = XmlTools.getChildNodeValue(columnNode, "name"); - Node pluginNode = XmlTools.getFirstNodeWithName(columnNode, "plugin"); - String pluginId = XmlTools.unmarshallText(pluginNode); + String pluginId = XmlTools.getChildNodeValue(columnNode, "plugin"); Plugin plugin = plugins.get(pluginId); Column column = new Column(name,plugin); Added: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Plugin.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Plugin.java 2005-12-17 15:21:32 UTC (rev 1833) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Plugin.java 2005-12-17 16:35:30 UTC (rev 1834) @@ -0,0 +1,49 @@ +/* + * 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; + +import org.jboss.forge.status.plugins.InvalidPluginPropertiesException; +import org.w3c.dom.Node; + +/** +* @author Pawel Wrzeszcz +*/ + +public abstract class Plugin { + + protected Node propertiesNode; + + protected String name; + protected String id; + + public void init(String name, String id, Node propertiesNode) throws InvalidPluginPropertiesException { + this.propertiesNode = propertiesNode; + this.name = name; + this.id = id; + } + + public abstract int getValue(String projectId); + + public String getId() { return id; }; + public String getName() { return name; }; +} Added: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Plugins.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Plugins.java 2005-12-17 15:21:32 UTC (rev 1833) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Plugins.java 2005-12-17 16:35:30 UTC (rev 1834) @@ -0,0 +1,125 @@ +/* + * 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; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +import org.jboss.forge.common.XmlTools; +import org.jboss.forge.common.projects.Projects; +import org.jboss.forge.status.plugins.InvalidPluginPropertiesException; +import org.jboss.forge.status.plugins.ScorePlugin; +import org.jboss.forge.status.plugins.StatusPlugin; +import org.jboss.logging.Logger; + +import org.w3c.dom.Node; + +/** +* @author Pawel Wrzeszcz +*/ + +public class Plugins {; + + private final static String PLUGIN_ID_ELEMENT = "id"; + private final static String PLUGIN_NAME_ELEMENT = "name"; + private final static String PLUGIN_CLASS_ELEMENT = "class"; + private final static String PLUGIN_PROPERTIES_ELEMENT = "properties"; + + Map<String, Plugin> plugins; + Projects projects; + + private Logger log; + + public Plugins(Set<Node> pluginsNodes, Projects projects, boolean scorePlugins) { + + this.projects = projects; + + log = Logger.getLogger(this.getClass()); + + plugins = new HashMap<String,Plugin>(); + + add(pluginsNodes, scorePlugins); + } + +private Plugin getPlugin(Node pluginNode, boolean scorePlugin) { + + // Get plugin info from pluginNode + + String pluginClassString = XmlTools.getChildNodeValue(pluginNode, PLUGIN_CLASS_ELEMENT); + String pluginName = XmlTools.getChildNodeValue(pluginNode, PLUGIN_NAME_ELEMENT); + String pluginId = XmlTools.getChildNodeValue(pluginNode, PLUGIN_ID_ELEMENT); + + // Get plugin class + Class pluginClass = null; + try { + pluginClass = Class.forName(pluginClassString); + } catch (ClassNotFoundException e) { + log.error("Plugin class not found: " + pluginClassString); + return null; + } + + Node pluginSpecificPropertiesNode = XmlTools.getFirstNodeWithName(pluginNode, PLUGIN_PROPERTIES_ELEMENT); + + // Get plugin instance; + Plugin plugin = null; + try { + plugin = (Plugin) pluginClass.newInstance(); + + if (scorePlugin) { + ((ScorePlugin) plugin).init(pluginName, pluginId, plugins.values(), pluginSpecificPropertiesNode); + } else { /* score plugin */ + ((StatusPlugin) plugin).init(pluginName, pluginId, projects, pluginSpecificPropertiesNode); + } + + } catch (InvalidPluginPropertiesException e) { + log.warn(e); + return null; + } + catch (Exception e) { + log.error("Plugin class: " + pluginClassString + ". Instantination failed.", e); + return null; + } + + System.out.println("[Status] Added plugin " + pluginClassString + "."); + + return plugin; + } + + public Plugin get(String pluginId) { + return plugins.get(pluginId); + } + + public void add(Set<Node> pluginsNodes, boolean scorePlugins) { + for (Iterator iter = pluginsNodes.iterator(); iter.hasNext();) { + Node pluginNode = (Node) iter.next(); + + Plugin plugin = getPlugin(pluginNode, scorePlugins); + + if (plugin != null) { + plugins.put(plugin.getId(), plugin); + } + } + } +} Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java 2005-12-17 15:21:32 UTC (rev 1833) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java 2005-12-17 16:35:30 UTC (rev 1834) @@ -22,20 +22,13 @@ package org.jboss.forge.status; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.HashMap; import java.util.Set; import java.util.HashSet; -import java.util.ArrayList; import org.jboss.forge.common.projects.Projects; import org.jboss.forge.common.projects.ProjectsHelper; -import org.jboss.forge.common.projects.permissions.NullPermissionsChecker; -import org.jboss.forge.common.projects.permissions.PermissionsChecker; + import org.jboss.forge.common.XmlTools; import org.jboss.forge.common.projects.AbstractDescriptor; import org.jboss.portal.common.context.DelegateContext; @@ -43,68 +36,47 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; -//import org.jboss.forge.status.plugins.InvalidPluginPropertiesException; -import org.jboss.forge.status.plugins.InvalidPluginPropertiesException; -import org.jboss.forge.status.plugins.Plugin; -import org.jboss.forge.status.plugins.ScorePlugin; -import org.jboss.forge.status.plugins.StatusPlugin; -import org.jboss.logging.Logger; /** * @author Pawel Wrzeszcz */ public class Status extends AbstractDescriptor { - + private final static String PLUGIN_ELEMENT = "plugin"; - private final static String PLUGIN_ID_ELEMENT = "id"; - private final static String PLUGIN_NAME_ELEMENT = "name"; - private final static String PLUGIN_CLASS_ELEMENT = "class"; - private final static String PLUGIN_WEIGHT_ELEMENT = "weight"; - private final static String PLUGIN_PROPERTIES_ELEMENT = "properties"; - private static final String MAIN_PAGE_COLLUMNS_TAG = "main"; - private static final String PROJECT_PAGE_COLLUMNS_TAG = "project"; + //private static final String PROJECT_PAGE_COLLUMNS_TAG = "project"; - private String portalName; - private Projects projects; private Columns mainPageColumns; - private Map<String, Plugin> statusPlugins; - private Map<String, Plugin> scorePlugins; - private Map<String, Plugin> allPlugins; + private Plugins plugins; - private Logger log; - - private HashSet<String> pluginsElements; - Status(String portalName, Node statusRoot, Node statusPluginsRoot, Node scorePluginsRoot) { - this.portalName = portalName; - - log = Logger.getLogger(this.getClass()); - initPluginElements(); + System.out.println("# 1 #"); // Get the projects projects = ProjectsHelper.getProjects(portalName); // Get the status plugins Set<Node> statusPluginsNodes = getPluginsNodes(statusPluginsRoot); - statusPlugins = getPlugins(statusPluginsNodes, false); + plugins = new Plugins(statusPluginsNodes, projects, false); - // Get the score plugins + System.out.println("# 2 #"); + + // Add the score plugins Set<Node> scorePluginsNodes = getPluginsNodes(scorePluginsRoot); - scorePlugins = getPlugins(scorePluginsNodes, true); + //plugins.putAll(scorePluginsNodes, true); - allPlugins = new HashMap<String, Plugin>(); - allPlugins.putAll(statusPlugins); - allPlugins.putAll(scorePlugins); + System.out.println("# 3 #"); // Get columns to display Node pageRoot = XmlTools.getFirstNodeWithName(statusRoot, MAIN_PAGE_COLLUMNS_TAG); - mainPageColumns = new Columns(pageRoot, allPlugins, projects); + mainPageColumns = new Columns(pageRoot, plugins, projects); + + System.out.println("# 4 #"); } private Set<Node> getPluginsNodes(Node pluginsRoot) { @@ -116,17 +88,6 @@ return pluginsNodes; } - private void initPluginElements() { - - pluginsElements = new HashSet<String>(); - - pluginsElements.add(PLUGIN_ID_ELEMENT); - pluginsElements.add(PLUGIN_NAME_ELEMENT); - pluginsElements.add(PLUGIN_CLASS_ELEMENT); - pluginsElements.add(PLUGIN_WEIGHT_ELEMENT); - pluginsElements.add(PLUGIN_PROPERTIES_ELEMENT); - } - /** * Fills the given context with podcast information. * @@ -135,68 +96,7 @@ public void fillContext(DelegateContext context) { mainPageColumns.fillContext(context); } - - private Map<String,Plugin> getPlugins(Set<Node> pluginsNodes, boolean scorePlugins) { - Map<String,Plugin> plugins = new HashMap<String,Plugin>(); - - for (Iterator iter = pluginsNodes.iterator(); iter.hasNext();) { - Node pluginNode = (Node) iter.next(); - - Plugin plugin = getPlugin(pluginNode, scorePlugins); - - if (plugin != null) { - plugins.put(plugin.getId(), plugin); - } - } - - return plugins; - } - private Plugin getPlugin(Node pluginNode, boolean scorePlugin) { - - // Get plugin info from pluginNode - - Map<String,Node> pluginProperties = getChildNodesMap(pluginNode, pluginsElements); - String pluginClassString = XmlTools.unmarshallText(pluginProperties.get(PLUGIN_CLASS_ELEMENT)); - String pluginName = XmlTools.unmarshallText(pluginProperties.get(PLUGIN_NAME_ELEMENT)); - String pluginId = XmlTools.unmarshallText(pluginProperties.get(PLUGIN_ID_ELEMENT)); - - // Get plugin class - Class pluginClass = null; - try { - pluginClass = Class.forName(pluginClassString); - } catch (ClassNotFoundException e) { - log.error("Plugin class not found: " + pluginClassString); - return null; - } - - Node pluginSpecificPropertiesNode = pluginProperties.get(PLUGIN_PROPERTIES_ELEMENT); - - // Get plugin instance; - Plugin plugin = null; - try { - plugin = (Plugin) pluginClass.newInstance(); - - if (scorePlugin) { - ((ScorePlugin) plugin).init(pluginName, pluginId, statusPlugins.values(), pluginSpecificPropertiesNode); - } else { /* score plugin */ - ((StatusPlugin) plugin).init(pluginName, pluginId, projects, pluginSpecificPropertiesNode); - } - - } catch (InvalidPluginPropertiesException e) { - log.warn(e); - return null; - } - catch (Exception e) { - log.error("Plugin class: " + pluginClassString + ". Instantination failed.", e); - return null; - } - - System.out.println("[Status] Added plugin " + pluginClassString + "."); - - return plugin; - } - /** * For the given Node, computes Set of it's child Nodes. * Only child Nodes with names included in <code>nodesNames</code> Set @@ -221,24 +121,4 @@ return ret; } - - /** - * Similar to <code>getChildNodesSet(Node,Set)</code>. - * Map binds child Nodes names with appropriate Nodes. - */ - private Map<String,Node> getChildNodesMap(Node root, Set<String> nodesNames) { - HashMap<String,Node> ret = new HashMap<String,Node>(); - NodeList list = root.getChildNodes(); - - for (int i = 0; i < list.getLength(); i++) { - Node n = list.item(i); - if ((n.getNodeType() == Node.ELEMENT_NODE) - && (nodesNames.contains(n.getNodeName()))) { - ret.put(n.getNodeName(),n); - } - } - - return ret; - } - } Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/StatusDescriptor.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/StatusDescriptor.java 2005-12-17 15:21:32 UTC (rev 1833) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/StatusDescriptor.java 2005-12-17 16:35:30 UTC (rev 1834) @@ -24,7 +24,6 @@ import java.io.IOException; import org.apache.xerces.parsers.DOMParser; -import org.jboss.forge.common.XmlTools; import org.jboss.portal.common.context.DelegateContext; import org.jboss.portlet.JBossRenderRequest; Deleted: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/Plugin.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/Plugin.java 2005-12-17 15:21:32 UTC (rev 1833) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/Plugin.java 2005-12-17 16:35:30 UTC (rev 1834) @@ -1,48 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2005, JBoss Inc., and individual contributors as indicated - * by the @authors tag. See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ - -package org.jboss.forge.status.plugins; - -import org.w3c.dom.Node; - -/** -* @author Pawel Wrzeszcz -*/ - -public abstract class Plugin { - - protected Node propertiesNode; - - protected String name; - protected String id; - - public void init(String name, String id, Node propertiesNode) throws InvalidPluginPropertiesException { - this.propertiesNode = propertiesNode; - this.name = name; - this.id = id; - } - - public abstract int getValue(String projectId); - - public String getId() { return id; }; - public String getName() { return name; }; -} Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/ScorePlugin.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/ScorePlugin.java 2005-12-17 15:21:32 UTC (rev 1833) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/ScorePlugin.java 2005-12-17 16:35:30 UTC (rev 1834) @@ -24,6 +24,7 @@ import java.util.Collection; +import org.jboss.forge.status.Plugin; import org.w3c.dom.Node; /** Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/StatusPlugin.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/StatusPlugin.java 2005-12-17 15:21:32 UTC (rev 1833) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/StatusPlugin.java 2005-12-17 16:35:30 UTC (rev 1834) @@ -23,6 +23,7 @@ package org.jboss.forge.status.plugins; import org.jboss.forge.common.projects.Projects; +import org.jboss.forge.status.Plugin; import org.w3c.dom.Node; Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/WeightedScorePlugin.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/WeightedScorePlugin.java 2005-12-17 15:21:32 UTC (rev 1833) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/WeightedScorePlugin.java 2005-12-17 16:35:30 UTC (rev 1834) @@ -24,6 +24,8 @@ import java.util.Iterator; +import org.jboss.forge.status.Plugin; + /** * @author Pawel Wrzeszcz */ |
From: <jbo...@li...> - 2005-12-17 15:21:37
|
Author: wrzep Date: 2005-12-17 10:21:32 -0500 (Sat, 17 Dec 2005) New Revision: 1833 Added: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Columns.java Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java Log: columns handling placed in Columns.java http://jira.jboss.com/jira/browse/JBLAB-415 Pawel Added: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Columns.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Columns.java 2005-12-17 15:00:05 UTC (rev 1832) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Columns.java 2005-12-17 15:21:32 UTC (rev 1833) @@ -0,0 +1,124 @@ +/* + * 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; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.jboss.forge.common.XmlTools; +import org.jboss.forge.common.projects.Projects; +import org.jboss.forge.common.projects.ProjectsHelper; +import org.jboss.forge.common.projects.permissions.NullPermissionsChecker; +import org.jboss.forge.common.projects.permissions.PermissionsChecker; +import org.jboss.forge.status.plugins.Plugin; +import org.jboss.portal.common.context.DelegateContext; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +/** +* @author Pawel Wrzeszcz +*/ +public class Columns { + + List<Column> columns; + Projects projects; + + public Columns(Node pageRoot, Map<String,Plugin> plugins, Projects projects) { + this.projects = projects; + + columns = new ArrayList<Column>(); + + NodeList columnsList = pageRoot.getChildNodes(); + for (int i = 0; i < columnsList.getLength(); i++) { + Node columnNode = columnsList.item(i); + + if (columnNode.getNodeType() == Node.ELEMENT_NODE) { + Node nameNode = XmlTools.getFirstNodeWithName(columnNode, "name"); + String name = XmlTools.unmarshallText(nameNode); + + Node pluginNode = XmlTools.getFirstNodeWithName(columnNode, "plugin"); + String pluginId = XmlTools.unmarshallText(pluginNode); + Plugin plugin = plugins.get(pluginId); + + Column column = new Column(name,plugin); + columns.add(column); + } + } + } + + public void fillContext(DelegateContext context) { + fillColumnsNames(context); + fillValues(context); + } + + private void fillColumnsNames(DelegateContext context) { + + for (Iterator iter = columns.iterator(); iter.hasNext();) { + Column column = (Column) iter.next(); + + DelegateContext columnContext = new DelegateContext(); + columnContext.put("name", column.getName()); + + context.append("collumn", columnContext); + } + } + + /** Fills the context with appropiate values (from each column) for each project. */ + private void fillValues(DelegateContext context) { + + Set<String> projectIds = projects.getProjectIds( + (PermissionsChecker) new NullPermissionsChecker(), null); + + int position = 0; + for (Iterator iter = projectIds.iterator(); iter.hasNext();) { + String projectId = (String) iter.next(); + position++; + + DelegateContext projectContext = context.next("project"); + fillProjectContext(projectContext, projectId, position); + } + } + + private void fillProjectContext(DelegateContext projectContext, + String projectId, int position) { + + projectContext.put("position", position); + + projectContext.put("name", projects.getProjectName(projectId)); + projectContext.put("link", projects.getProjectLink(projectId)); + + fillEntries(projectContext, columns, projectId); +} + + private void fillEntries(DelegateContext projectContext, Collection<Column> columns, String projectId) { + for (Iterator iter = columns.iterator(); iter.hasNext();) { + Column column = (Column) iter.next(); + + column.fillProjectContext(projectContext, projectId); + } + } +} Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java 2005-12-17 15:00:05 UTC (rev 1832) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java 2005-12-17 15:21:32 UTC (rev 1833) @@ -70,7 +70,7 @@ private Projects projects; - private List<Column> mainPageColumns; + private Columns mainPageColumns; private Map<String, Plugin> statusPlugins; private Map<String, Plugin> scorePlugins; @@ -103,34 +103,9 @@ allPlugins.putAll(scorePlugins); // Get columns to display - mainPageColumns = getPageColumns(statusRoot, MAIN_PAGE_COLLUMNS_TAG); + Node pageRoot = XmlTools.getFirstNodeWithName(statusRoot, MAIN_PAGE_COLLUMNS_TAG); + mainPageColumns = new Columns(pageRoot, allPlugins, projects); } - - private List<Column> getPageColumns(Node statusRoot, String nodeTag) { - - List<Column> columns = new ArrayList<Column>(); - - Node pageRoot = XmlTools.getFirstNodeWithName(statusRoot, nodeTag); - - NodeList columnsList = pageRoot.getChildNodes(); - for (int i = 0; i < columnsList.getLength(); i++) { - Node columnNode = columnsList.item(i); - - if (columnNode.getNodeType() == Node.ELEMENT_NODE) { - Node nameNode = XmlTools.getFirstNodeWithName(columnNode, "name"); - String name = XmlTools.unmarshallText(nameNode); - - Node pluginNode = XmlTools.getFirstNodeWithName(columnNode, "plugin"); - String pluginId = XmlTools.unmarshallText(pluginNode); - Plugin plugin = allPlugins.get(pluginId); - - Column column = new Column(name,plugin); - columns.add(column); - } - } - - return columns; - } private Set<Node> getPluginsNodes(Node pluginsRoot) { @@ -157,59 +132,10 @@ * * @param context Context to fill. */ - public void fillContext(DelegateContext context) { - - fillColumnsNames(context); - fillValues(context); + public void fillContext(DelegateContext context) { + mainPageColumns.fillContext(context); } - - private void fillColumnsNames(DelegateContext context) { - - for (Iterator iter = mainPageColumns.iterator(); iter.hasNext();) { - Column column = (Column) iter.next(); - - DelegateContext columnContext = new DelegateContext(); - columnContext.put("name", column.getName()); - - context.append("collumn", columnContext); - } - } - - /** Fills the context with appropiate values (from each column) for each project. */ - private void fillValues(DelegateContext context) { - - Set<String> projectIds = projects.getProjectIds( - (PermissionsChecker) new NullPermissionsChecker(), null); - - int position = 0; - for (Iterator iter = projectIds.iterator(); iter.hasNext();) { - String projectId = (String) iter.next(); - position++; - - DelegateContext projectContext = context.next("project"); - fillProjectContext(projectContext, projectId, position); - } - } - private void fillProjectContext(DelegateContext projectContext, - String projectId, int position) { - - projectContext.put("position", position); - - projectContext.put("name", projects.getProjectName(projectId)); - projectContext.put("link", projects.getProjectLink(projectId)); - - fillEntries(projectContext, mainPageColumns, projectId); - } - - private void fillEntries(DelegateContext projectContext, Collection<Column> columns, String projectId) { - for (Iterator iter = columns.iterator(); iter.hasNext();) { - Column column = (Column) iter.next(); - - column.fillProjectContext(projectContext, projectId); - } - } - private Map<String,Plugin> getPlugins(Set<Node> pluginsNodes, boolean scorePlugins) { Map<String,Plugin> plugins = new HashMap<String,Plugin>(); |