← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15612: fix for UserCredentials

 

------------------------------------------------------------
revno: 15612
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-06-10 18:59:51 +0200
message:
  fix for UserCredentials
added:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/UserCredentialsSchemaDescriptor.java
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/AbstractNode.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Property.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserCredentials.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/filter/DefaultFilterService.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SchemaController.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/AbstractNode.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/AbstractNode.java	2014-06-08 10:58:50 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/AbstractNode.java	2014-06-10 16:59:51 +0000
@@ -216,7 +216,7 @@
         return Objects.toStringHelper( this )
             .add( "name", name )
             .add( "nodeType", nodeType )
-            .add( "parent", parent.getName() )
+            .add( "parent", (parent != null ? parent.getName() : null) )
             .add( "namespace", namespace )
             .add( "comment", comment )
             .add( "children", children )

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Property.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Property.java	2014-06-09 14:26:55 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Property.java	2014-06-10 16:59:51 +0000
@@ -50,13 +50,13 @@
     /**
      * Class for property.
      */
-    @NodeSimple
+    @NodeSimple( isPersisted = false )
     private Class<?> klass;
 
     /**
      * If this property is a collection, this is the class of the items inside the collection.
      */
-    @NodeSimple
+    @NodeSimple( isPersisted = false )
     private Class<?> itemKlass;
 
     /**
@@ -73,32 +73,32 @@
      * Name for this property, if this class is a collection, it is the name of the items -inside- the collection
      * and not the collection wrapper itself.
      */
-    @NodeSimple
+    @NodeSimple( isPersisted = false )
     private String name;
 
     /**
      * Name for actual field, used to persistence operations and getting setter/getter.
      */
-    @NodeSimple
+    @NodeSimple( isPersisted = false )
     private String fieldName;
 
     /**
      * Is this property persisted somewhere. This property will be used to create criteria queries
      * on demand (default: true)
      */
-    @NodeSimple
+    @NodeSimple( isPersisted = false )
     private boolean persisted = true;
 
     /**
      * Name of collection wrapper.
      */
-    @NodeSimple
+    @NodeSimple( isPersisted = false )
     private String collectionName;
 
     /**
      * If this Property is a collection, should it be wrapped with collectionName?
      */
-    @NodeSimple
+    @NodeSimple( isPersisted = false )
     private boolean collectionWrapping;
 
     /**
@@ -106,19 +106,19 @@
      *
      * @see org.hisp.dhis.common.annotation.Description
      */
-    @NodeSimple
+    @NodeSimple( isPersisted = false )
     private String description;
 
     /**
-     * XML-Namespace used for this property.
+     * Namespace used for this property.
      */
-    @NodeSimple
+    @NodeSimple( isPersisted = false )
     private String namespace;
 
     /**
      * Usually only used for XML. Is this property considered an attribute.
      */
-    @NodeSimple
+    @NodeSimple( isPersisted = false )
     private boolean attribute;
 
     /**
@@ -127,7 +127,7 @@
      * of the collection, e.g. List<String> would set simple to be true, but List<DataElement> would set it
      * to false.
      */
-    @NodeSimple
+    @NodeSimple( isPersisted = false )
     private boolean simple;
 
     /**
@@ -135,7 +135,7 @@
      *
      * @see java.util.Collection
      */
-    @NodeSimple
+    @NodeSimple( isPersisted = false )
     private boolean collection;
 
     /**
@@ -143,7 +143,7 @@
      *
      * @see org.hisp.dhis.common.IdentifiableObject
      */
-    @NodeSimple
+    @NodeSimple( isPersisted = false )
     private boolean identifiableObject;
 
     /**
@@ -151,7 +151,7 @@
      *
      * @see org.hisp.dhis.common.NameableObject
      */
-    @NodeSimple
+    @NodeSimple( isPersisted = false )
     private boolean nameableObject;
 
     public Property()

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/UserCredentialsSchemaDescriptor.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/UserCredentialsSchemaDescriptor.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/UserCredentialsSchemaDescriptor.java	2014-06-10 16:59:51 +0000
@@ -0,0 +1,54 @@
+package org.hisp.dhis.schema.descriptors;
+
+/*
+ * Copyright (c) 2004-2014, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
+ */
+
+import org.hisp.dhis.schema.Schema;
+import org.hisp.dhis.schema.SchemaDescriptor;
+import org.hisp.dhis.user.UserCredentials;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+@Component
+public class UserCredentialsSchemaDescriptor implements SchemaDescriptor
+{
+    public static final String SINGULAR = "userCredentials";
+
+    public static final String PLURAL = "userCredentials";
+
+    @Override
+    public Schema getSchema()
+    {
+        Schema schema = new Schema( UserCredentials.class, SINGULAR, PLURAL );
+        schema.setOrder( 2000 );
+
+        return schema;
+    }
+}

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserCredentials.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserCredentials.java	2014-05-27 02:41:16 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserCredentials.java	2014-06-10 16:59:51 +0000
@@ -57,7 +57,7 @@
 /**
  * @author Nguyen Hong Duc
  */
-@JacksonXmlRootElement(localName = "userCredentials", namespace = DxfNamespaces.DXF_2_0)
+@JacksonXmlRootElement( localName = "userCredentials", namespace = DxfNamespaces.DXF_2_0 )
 public class UserCredentials
     extends BaseIdentifiableObject
 {
@@ -456,7 +456,7 @@
     }
 
     @JsonProperty
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public void setPassword( String password )
     {
         this.password = password;

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/filter/DefaultFilterService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/filter/DefaultFilterService.java	2014-06-09 12:27:37 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/filter/DefaultFilterService.java	2014-06-10 16:59:51 +0000
@@ -157,12 +157,14 @@
             Object returnValue = ReflectionUtils.invokeMethod( object, property.getGetterMethod() );
             Schema propertySchema = schemaService.getDynamicSchema( property.getKlass() );
 
+            // TODO should we include nulls?
             if ( returnValue == null )
             {
                 continue;
             }
 
             Map fieldValue = fieldMap.get( fieldKey );
+            updateFields( fieldValue, object );
 
             if ( fieldValue.isEmpty() )
             {
@@ -287,6 +289,11 @@
             {
                 List<String> fields = FIELD_PRESETS.get( fieldKey.substring( 1 ) );
 
+                if ( fields == null )
+                {
+                    continue;
+                }
+
                 for ( String field : fields )
                 {
                     if ( !fieldMap.containsKey( field ) )

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SchemaController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SchemaController.java	2014-06-09 14:26:55 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SchemaController.java	2014-06-10 16:59:51 +0000
@@ -28,7 +28,9 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import org.hisp.dhis.schema.NodePropertyIntrospectorService;
 import org.hisp.dhis.schema.Property;
+import org.hisp.dhis.schema.PropertyIntrospectorService;
 import org.hisp.dhis.schema.Schema;
 import org.hisp.dhis.schema.SchemaService;
 import org.hisp.dhis.schema.Schemas;
@@ -39,6 +41,8 @@
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.ResponseBody;
 
+import java.util.Map;
+
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
  */