cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From un...@apache.org
Subject cvs commit: cocoon-2.2/src/java/org/apache/cocoon/components/treeprocessor sitemap2xconf.xsl
Date Mon, 01 Dec 2003 22:36:01 GMT
unico       2003/12/01 14:36:01

  Modified:    src/java/org/apache/cocoon/components/treeprocessor/sitemap
                        ViewRegistry.java ViewRegistryImpl.java
               src/test/org/apache/cocoon/components/treeprocessor/sitemap
                        ViewRegistryTestCase.java
               src/java/org/apache/cocoon/components/treeprocessor
                        sitemap2xconf.xsl
  Log:
  transparent sitemap role identification
  
  Revision  Changes    Path
  1.3       +2 -2      cocoon-2.2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ViewRegistry.java
  
  Index: ViewRegistry.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ViewRegistry.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ViewRegistry.java	1 Dec 2003 22:05:49 -0000	1.2
  +++ ViewRegistry.java	1 Dec 2003 22:36:01 -0000	1.3
  @@ -66,10 +66,10 @@
        * collection, the statement can directly branch to the view-handling node.
        *
        * @param role the component role (e.g. <code>Generator.ROLE</code>)
  -     * @param componenId the lookup id of the sitemap component (e.g. <code>file-generator</code>).
  +     * @param componenId the component hint, i.e. the 'type' attribute (e.g. <code>file</code>).
        * @param statement the sitemap statement
        * @return the view names for this statement
        */
  -    Collection getViewsForStatement(String role, String componentId, Configuration statement);
  +    Collection getViewsForStatement(String role, String hint, Configuration statement);
       
   }
  
  
  
  1.3       +12 -1     cocoon-2.2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ViewRegistryImpl.java
  
  Index: ViewRegistryImpl.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ViewRegistryImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ViewRegistryImpl.java	1 Dec 2003 22:05:49 -0000	1.2
  +++ ViewRegistryImpl.java	1 Dec 2003 22:36:01 -0000	1.3
  @@ -65,6 +65,7 @@
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.cocoon.generation.Generator;
   import org.apache.cocoon.serialization.Serializer;
  +import org.apache.cocoon.transformation.Transformer;
   import org.apache.cocoon.util.StringUtils;
   import org.apache.cocoon.xml.LocationAugmentationPipe;
   
  @@ -98,6 +99,14 @@
       private static final String FROM_LABEL_ATTR = "from-label";
       private static final String FROM_POSITION_ATTR = "from-position";
       
  +    
  +    private static final Map ROLE2ID_SUFFIX = new HashMap(3);
  +    static {
  +        ROLE2ID_SUFFIX.put(Generator.ROLE,"-generator");
  +        ROLE2ID_SUFFIX.put(Transformer.ROLE,"-transformer");
  +        ROLE2ID_SUFFIX.put(Serializer.ROLE,"-serializer");
  +    }
  +    
       // component ids -> labels
       private Map m_componentLabels;
       
  @@ -142,13 +151,15 @@
       
       // ---------------------------------------------------- ViewRegistry implementation
       
  -    public Collection getViewsForStatement(String role, String componentId, Configuration
statement) {
  +    public Collection getViewsForStatement(String role, String hint, Configuration statement)
{
           
           // Compute the views attached to this component
           Set views = null;
   
           // Build the set of all labels for this statement
           Set labels = new HashSet();
  +        
  +        String componentId = hint + ROLE2ID_SUFFIX.get(role);
           
           // 1 - labels defined on the component
           Collection componentLabels = (Collection) m_componentLabels.get(componentId);
  
  
  
  1.2       +9 -3      cocoon-2.2/src/test/org/apache/cocoon/components/treeprocessor/sitemap/ViewRegistryTestCase.java
  
  Index: ViewRegistryTestCase.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/test/org/apache/cocoon/components/treeprocessor/sitemap/ViewRegistryTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ViewRegistryTestCase.java	1 Dec 2003 22:04:53 -0000	1.1
  +++ ViewRegistryTestCase.java	1 Dec 2003 22:36:01 -0000	1.2
  @@ -71,18 +71,24 @@
       public void testGetViewForStatement() throws Exception {
           ViewRegistry vr = (ViewRegistry) super.lookup(ViewRegistry.class.getName());
           
  -        Collection views = vr.getViewsForStatement(Generator.ROLE, "some-generator", createEmptyStatement());
  +        Collection views = vr.getViewsForStatement(Generator.ROLE, "some", createEmptyStatement());
  +        assertTrue(views != null);
           assertTrue(views.size() == 3);
           assertTrue(views.contains("firstview"));
           assertTrue(views.contains("gen1view"));
           assertTrue(views.contains("gen2view"));
           
  -        views = vr.getViewsForStatement(Transformer.ROLE, "some-transformer", createLabeledStatement("trans2"));
  +        views = vr.getViewsForStatement(Transformer.ROLE, "some", createLabeledStatement("trans2"));
  +        assertTrue(views != null);        
           assertTrue(views.size() == 2);
           assertTrue(views.contains("trans1view"));
           assertTrue(views.contains("trans2view"));
  +        
  +        views = vr.getViewsForStatement(Transformer.ROLE, "someother", createEmptyStatement());
  +        assertTrue(views == null);
   
  -        views = vr.getViewsForStatement(Serializer.ROLE, "some-serializer", createEmptyStatement());
  +        views = vr.getViewsForStatement(Serializer.ROLE, "some", createEmptyStatement());
  +        assertTrue(views != null);
           assertTrue(views.size() == 1);
           assertTrue(views.contains("lastview"));
       }
  
  
  
  1.4       +2 -4      cocoon-2.2/src/java/org/apache/cocoon/components/treeprocessor/sitemap2xconf.xsl
  
  Index: sitemap2xconf.xsl
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/treeprocessor/sitemap2xconf.xsl,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- sitemap2xconf.xsl	30 Nov 2003 21:16:15 -0000	1.3
  +++ sitemap2xconf.xsl	1 Dec 2003 22:36:01 -0000	1.4
  @@ -10,10 +10,8 @@
       <sitemap>
         <xsl:apply-templates select="map:components|map:views|map:resources|map:action-sets|map:pipelines"/>
         <view-registry id="default">
  -        <xsl:for-each select="/map:sitemap/map:components/*/*">
  -          <xsl:if test="@label">
  -            <component id-ref="{@name}-{local-name()}" label="{@label}" />
  -          </xsl:if>
  +        <xsl:for-each select="/map:sitemap/map:components/*/*[@label]">
  +          <component id-ref="{@name}-{local-name()}" label="{@label}" />
           </xsl:for-each>
           <xsl:for-each select="/map:sitemap/map:views/*">
             <view id-ref="v-{position()}">
  
  
  

Mime
View raw message