maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sisb...@apache.org
Subject svn commit: r689183 - in /maven/shared/trunk/maven-shared-model/src/main/java/org/apache/maven/shared/model: ModelTransformerContext.java impl/DefaultModelDataSource.java
Date Tue, 26 Aug 2008 19:48:01 GMT
Author: sisbell
Date: Tue Aug 26 12:48:00 2008
New Revision: 689183

URL: http://svn.apache.org/viewvc?rev=689183&view=rev
Log:
Fixed bug: If a node tag was empty, then the model property would be treated as text field.
This caused the xml model generation to fail if it inherited a similar node that wasn't empty.

Modified:
    maven/shared/trunk/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelTransformerContext.java
    maven/shared/trunk/maven-shared-model/src/main/java/org/apache/maven/shared/model/impl/DefaultModelDataSource.java

Modified: maven/shared/trunk/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelTransformerContext.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelTransformerContext.java?rev=689183&r1=689182&r2=689183&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelTransformerContext.java
(original)
+++ maven/shared/trunk/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelTransformerContext.java
Tue Aug 26 12:48:00 2008
@@ -89,6 +89,7 @@
         if(modelPropertyTransformers == null) {
             throw new IllegalArgumentException("modelPropertyTransformers: null");
         }
+        
         List<ModelProperty> properties = new ArrayList<ModelProperty>(modelProperties);
         List<ModelPropertyTransformer> transformers = new ArrayList<ModelPropertyTransformer>(modelPropertyTransformers);
         for(ModelPropertyTransformer mpt : transformers) {
@@ -123,9 +124,20 @@
         List<ModelProperty> transformedProperties =
                 importModelProperties(importModels, fromModelTransformer.transformToModelProperties(
domainModels ));
 
+        List<ModelProperty> emptyTags = new ArrayList<ModelProperty>();
+        for(ModelProperty mp: transformedProperties)
+        {
+            if(isEmptyTag(mp, transformedProperties))
+            {    
+                emptyTags.add(mp);
+            }
+        }
+        transformedProperties.removeAll(emptyTags);
+
         String baseUriForModel = fromModelTransformer.getBaseUri();
         List<ModelProperty> modelProperties =
             sort( transformedProperties, baseUriForModel );
+
         ModelDataSource modelDataSource = new DefaultModelDataSource();
         modelDataSource.init( modelProperties, factories );
 
@@ -218,7 +230,7 @@
         try
         {
             DomainModel domainModel = toModelTransformer.transformToDomainModel( mps );
-            //domainModel.setEventHistory(modelDataSource.getEventHistory());
+            domainModel.setEventHistory(modelDataSource.getEventHistory());
             return domainModel;
         }
         catch ( IOException e )
@@ -303,4 +315,21 @@
         }
         return processedProperties;
     }
+    
+    private static boolean isEmptyTag(ModelProperty modelProperty, List<ModelProperty>
modelProperties)
+    {
+        if(modelProperty.getValue() != null)
+        {
+            return modelProperty.getValue().trim().equals("");
+        }
+
+        String uri = modelProperty.getUri();
+        for(ModelProperty mp: modelProperties) {
+            if(mp.getUri().startsWith(uri))
+            {
+                return false;
+            }
+        }
+        return true;
+    }
 }
\ No newline at end of file

Modified: maven/shared/trunk/maven-shared-model/src/main/java/org/apache/maven/shared/model/impl/DefaultModelDataSource.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-model/src/main/java/org/apache/maven/shared/model/impl/DefaultModelDataSource.java?rev=689183&r1=689182&r2=689183&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-model/src/main/java/org/apache/maven/shared/model/impl/DefaultModelDataSource.java
(original)
+++ maven/shared/trunk/maven-shared-model/src/main/java/org/apache/maven/shared/model/impl/DefaultModelDataSource.java
Tue Aug 26 12:48:00 2008
@@ -364,15 +364,14 @@
                 throw new IllegalArgumentException(
                     "Base URI is longer than model property uri: Base URI = " + baseUri +
", ModelProperty = " + p );
             }
-            String subUri = p.getUri().substring( baseUri.length(), modelPropertyLength );
 
+           String subUri = p.getUri().substring( baseUri.length(), modelPropertyLength );
             if ( !uris.contains( p.getUri() ) || ( subUri.contains( "#collection" ) &&
                 (!subUri.endsWith( "#collection" ) && !subUri.endsWith("#set")) &&
                 ( !combineChildrenUris.contains( p.getUri() ) || p.getUri().endsWith( "#property/combine.children"
) ) ) )
             {
-
-                processedProperties.add( findLastIndexOfParent( p, processedProperties )
+ 1, p );
-                uris.add( p.getUri() );
+                    processedProperties.add( findLastIndexOfParent( p, processedProperties
) + 1, p );
+                    uris.add( p.getUri() );
             }
             //if parentUri ends in set and uri is contained don't include it
         }



Mime
View raw message