[Dhis2-devs] [Bug 1538063] [NEW] Option Set list not available in aggregate data entry

2016-01-26 Thread Adebusoye Anifalaje
Public bug reported:

Hi devs,

Using DHIS 2.22 Version 21782

I created a Zero_Pos_Int option set with 5 options. Labels are text but
the codes are integers. This option set is assigned to data elements of
the same value type. On the data entry screen, the drop down returns 'No
matches found' for any of the options you enter.

To replicate on demo

1) In data entry, select Sierra Leone
2)  Select Facility Assessment data set and any period
3) Under Equipment section, click on dropdown arrow next to option set field
4) No Options shown (should have listed 1 - 5)
5) Type in any number between 1 and 5 (inclusive)

You get 'No matches found'.

I have included a copy of my browser console error log and also a
screenshot of what happens on the UI.

Thanks

** Affects: dhis2
 Importance: Undecided
 Status: New

** Attachment added: "Option Set List Error.png"
   
https://bugs.launchpad.net/bugs/1538063/+attachment/4556765/+files/Option%20Set%20List%20Error.png

-- 
You received this bug notification because you are a member of DHIS 2
developers, which is subscribed to DHIS.
https://bugs.launchpad.net/bugs/1538063

Title:
  Option Set list not available in aggregate data entry

Status in DHIS:
  New

Bug description:
  Hi devs,

  Using DHIS 2.22 Version 21782

  I created a Zero_Pos_Int option set with 5 options. Labels are text
  but the codes are integers. This option set is assigned to data
  elements of the same value type. On the data entry screen, the drop
  down returns 'No matches found' for any of the options you enter.

  To replicate on demo

  1) In data entry, select Sierra Leone
  2)  Select Facility Assessment data set and any period
  3) Under Equipment section, click on dropdown arrow next to option set field
  4) No Options shown (should have listed 1 - 5)
  5) Type in any number between 1 and 5 (inclusive)

  You get 'No matches found'.

  I have included a copy of my browser console error log and also a
  screenshot of what happens on the UI.

  Thanks

To manage notifications about this bug go to:
https://bugs.launchpad.net/dhis2/+bug/1538063/+subscriptions

___
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp


[Dhis2-devs] [Bug 1453569] Re: Sharing Feature not working for Dashboards

2016-01-26 Thread Morten Olav Hansen
Should now be fixed in latest 2.21, 2.22, and trunk. Please give our
servers about 30-40 min before you download a new version.

-- 
You received this bug notification because you are a member of DHIS 2
developers, which is subscribed to DHIS.
https://bugs.launchpad.net/bugs/1453569

Title:
  Sharing Feature not working for Dashboards

Status in DHIS:
  Fix Committed

Bug description:
  Dashboards do not respect sharing settings when configured .  For
  instance users who have not been given the authority to edit a
  dashboard can do so . Replicated on the demo server ( To do this ,
  create a dashboard and assign only read permissions to "public" , then
  create a new user and login - new user can edit contents of dashboard
  )

  Affects 2.18 Rev 18411

To manage notifications about this bug go to:
https://bugs.launchpad.net/dhis2/+bug/1453569/+subscriptions

___
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp


[Dhis2-devs] [Branch ~dhis2-devs-core/dhis2/trunk] Rev 21819: Speed up metadata export using Query.setUser(), gets rid of repeated getCurrentUser() calls

2016-01-26 Thread noreply

revno: 21819
committer: Morten Olav Hansen 
branch nick: dhis2
timestamp: Wed 2016-01-27 14:34:02 +0700
message:
  Speed up metadata export using Query.setUser(), gets rid of repeated 
getCurrentUser() calls
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardItem.java
  
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/CriteriaQueryEngine.java
  
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/Query.java
  
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/DefaultMetadataExportService.java
  
dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.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/dashboard/DashboardItem.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardItem.java	2016-01-04 02:27:49 +
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardItem.java	2016-01-27 07:34:02 +
@@ -95,7 +95,7 @@
 
 public DashboardItem()
 {
-setAutoFields();
+
 }
 
 public DashboardItem( String uid )

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/CriteriaQueryEngine.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/CriteriaQueryEngine.java	2016-01-04 06:04:35 +
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/CriteriaQueryEngine.java	2016-01-27 07:34:02 +
@@ -36,6 +36,7 @@
 import org.hisp.dhis.hibernate.HibernateGenericStore;
 import org.hisp.dhis.schema.Property;
 import org.hisp.dhis.schema.Schema;
+import org.hisp.dhis.user.CurrentUserService;
 import org.springframework.beans.factory.annotation.Autowired;
 
 import java.util.ArrayList;
@@ -54,6 +55,9 @@
 implements QueryEngine
 {
 @Autowired
+private CurrentUserService currentUserService;
+
+@Autowired
 private final List hibernateGenericStores = new ArrayList<>();
 
 private Map stores = new HashMap<>();
@@ -76,7 +80,12 @@
 return new ArrayList<>();
 }
 
-Criteria criteria = buildCriteria( store.getSharingCriteria(), query );
+if ( query.getUser() == null )
+{
+query.setUser( currentUserService.getCurrentUser() );
+}
+
+Criteria criteria = buildCriteria( store.getSharingCriteria( query.getUser() ), query );
 
 if ( criteria == null )
 {
@@ -108,7 +117,12 @@
 return 0;
 }
 
-Criteria criteria = buildCriteria( store.getSharingCriteria(), countQuery );
+if ( query.getUser() == null )
+{
+query.setUser( currentUserService.getCurrentUser() );
+}
+
+Criteria criteria = buildCriteria( store.getSharingCriteria( query.getUser() ), countQuery );
 
 if ( criteria == null )
 {

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/Query.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/Query.java	2016-01-05 07:53:54 +
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/Query.java	2016-01-27 07:34:02 +
@@ -31,6 +31,7 @@
 import com.google.common.base.MoreObjects;
 import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.schema.Schema;
+import org.hisp.dhis.user.User;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -41,6 +42,8 @@
  */
 public class Query extends Criteria
 {
+private User user;
+
 private List orders = new ArrayList<>();
 
 private Integer firstResult = 0;
@@ -92,6 +95,16 @@
 orders.clear();
 }
 
+public User getUser()
+{
+return user;
+}
+
+public void setUser( User user )
+{
+this.user = user;
+}
+
 public Integer getFirstResult()
 {
 return firstResult;

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/DefaultMetadataExportService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/DefaultMetadataExportService.java	2016-01-27 07:18:12 +
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/DefaultMetadataExportService.java	2016-01-27 07:34:02 +
@@ -35,6 +35,8 @@
 import org.hisp.dhis.query.QueryService;
 import org.hisp.dhis.schema.Schema;
 import org.hisp.dhis.schema.SchemaService;
+import org.hisp.dhis.user.CurrentUserService;
+import org.hisp.dhis.user.User;
 import 

Re: [Dhis2-devs] DHIS2 Issues with Dashboard

2016-01-26 Thread Archana Chillala
Hi Morten,

I did try what you suggested (for Issue 2), but it still does not fix it.

Archana Chillala
Application Developer
Email archa...@thoughtworks.com
Telephone +91 9100960533 <+91+9100960533>
[image: ThoughtWorks]


On Fri, Jan 22, 2016 at 4:48 PM, Morten Olav Hansen 
wrote:

> *Issue 1:*
>>
>> When we share a dashboard with a user Group providing* 'View Only'*
>> access, the users within that user group are also able to* EDIT *the
>> dashboard and make all sorts of changes that can be done (even though Edit
>> access is not given to them). And these changes are reflected
>> immediately across all the users within that group. We also tested this
>> with different roles giving minimum authorities. Yet, the same result.
>> How do we fix this?
>>
>
> I haven't seen this one before, will try to reproduce and fix.
>
>
>> *Issue 2:*
>>
>> We have two instances of DHIS. A dashboard is created and shared with a
>> user Group in the first instance. When, metadata is exported and imported
>> to the other DHIS instance, except the 'admin' user, no other user is able
>> to see any dashboards.
>>
>> Would you suggest any solution to this?
>>
>
> Did you try to enable sharing for import? (default is off)
>
> http://dhis2.github.io/dhis2-docs/master/en/developer/html/ch01s07.html#d5e388
>
> --
> Morten
>
>
>>
>>
>>
>> Thanks & Regards,
>>
>> Archana Chillala
>> Application Developer
>> Email archa...@thoughtworks.com
>> Telephone +91 9100960533 <+91+9100960533>
>> [image: ThoughtWorks]
>> 
>>
>> ___
>> Mailing list: https://launchpad.net/~dhis2-devs
>> Post to : dhis2-devs@lists.launchpad.net
>> Unsubscribe : https://launchpad.net/~dhis2-devs
>> More help   : https://help.launchpad.net/ListHelp
>>
>>
>
___
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp


Re: [Dhis2-devs] [Bug 1536817] [NEW] Metadata Import slower in 2.21

2016-01-26 Thread Timothy Harding
Thanks for reporting this one Jim, I'm seeing the same thing, about a 3 to
4x increase in metaData importation time with 2.21 over 2.20.


*Timothy Harding*
Sr. Systems Analyst, BAO Systems
+1 202-536-1541 | thard...@baosystems.com | http://www.baosystems.com | Skype:
hardi...@gmail.com | 2900 K Street, Suite 404, Washington D.C. 20007

On Fri, Jan 22, 2016 at 7:37 AM, Jim Grace <1536...@bugs.launchpad.net>
wrote:

> Public bug reported:
>
> A metadata import of 1090 data elements (with user group sharing
> information) that took 946 seconds in v2.20, took 2,932 seconds in
> v2.21.
>
> I can supply the import to developers.
>
> ** Affects: dhis2
>  Importance: Undecided
>  Status: New
>
> --
> You received this bug notification because you are a member of DHIS 2
> developers, which is subscribed to DHIS.
> https://bugs.launchpad.net/bugs/1536817
>
> Title:
>   Metadata Import slower in 2.21
>
> Status in DHIS:
>   New
>
> Bug description:
>   A metadata import of 1090 data elements (with user group sharing
>   information) that took 946 seconds in v2.20, took 2,932 seconds in
>   v2.21.
>
>   I can supply the import to developers.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/dhis2/+bug/1536817/+subscriptions
>
> ___
> Mailing list: https://launchpad.net/~dhis2-devs
> Post to : dhis2-devs@lists.launchpad.net
> Unsubscribe : https://launchpad.net/~dhis2-devs
> More help   : https://help.launchpad.net/ListHelp
>
___
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp


[Dhis2-devs] [Branch ~dhis2-devs-core/dhis2/trunk] Rev 21818: Support enable/disable of metadata export type in /api/metadata/export

2016-01-26 Thread noreply

revno: 21818
committer: Morten Olav Hansen 
branch nick: dhis2
timestamp: Wed 2016-01-27 14:18:12 +0700
message:
  Support enable/disable of metadata export type in /api/metadata/export
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/SchemaService.java
  
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/DefaultSchemaService.java
  
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/DefaultMetadataExportService.java
  
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/MetadataExportService.java
  
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/metadata/MetadataExportController.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/schema/SchemaService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/SchemaService.java	2016-01-04 02:27:49 +
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/SchemaService.java	2016-01-27 07:18:12 +
@@ -65,6 +65,15 @@
 Schema getSchemaBySingularName( String name );
 
 /**
+ * Get schema which has been generated by a SchemaDescriptor by singular name.
+ *
+ * @param name Name to get Schema for, will be matched against Schema.getSingular().
+ * @return Schema for class, or null
+ * @see org.hisp.dhis.schema.SchemaDescriptor
+ */
+Schema getSchemaByPluralName( String name );
+
+/**
  * Get all available schemas (which are generated with a schema descriptor).
  *
  * @return List of all available schemas

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/DefaultSchemaService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/DefaultSchemaService.java	2016-01-04 02:27:49 +
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/DefaultSchemaService.java	2016-01-27 07:18:12 +
@@ -56,6 +56,8 @@
 
 private Map singularSchemaMap = new HashMap<>();
 
+private Map pluralSchemaMap = new HashMap<>();
+
 private Map dynamicClassSchemaMap = new HashMap<>();
 
 @Autowired
@@ -92,6 +94,7 @@
 
 classSchemaMap.put( schema.getKlass(), schema );
 singularSchemaMap.put( schema.getSingular(), schema );
+pluralSchemaMap.put( schema.getPlural(), schema );
 
 updateSelf( schema );
 }
@@ -173,6 +176,12 @@
 }
 
 @Override
+public Schema getSchemaByPluralName( String name )
+{
+return pluralSchemaMap.get( name );
+}
+
+@Override
 public List getSchemas()
 {
 return Lists.newArrayList( classSchemaMap.values() );

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/DefaultMetadataExportService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/DefaultMetadataExportService.java	2016-01-27 03:17:41 +
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/DefaultMetadataExportService.java	2016-01-27 07:18:12 +
@@ -28,6 +28,8 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.query.Query;
 import org.hisp.dhis.query.QueryService;
@@ -36,6 +38,7 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -46,6 +49,8 @@
 @Component
 public class DefaultMetadataExportService implements MetadataExportService
 {
+private static final Log log = LogFactory.getLog( MetadataExportService.class );
+
 @Autowired
 private SchemaService schemaService;
 
@@ -64,6 +69,8 @@
 .forEach( schema -> params.getClasses().add( (Class) schema.getKlass() ) );
 }
 
+log.info( "Export started at " + new Date() );
+
 for ( Class klass : params.getClasses() )
 {
 Query query;
@@ -79,9 +86,12 @@
 }
 
 List objects = queryService.query( query );
+log.info( "Exported " + objects.size() + " objects of type " + klass.getSimpleName() );
 metadata.put( klass, objects );
 }
 
+log.info( "Export done at " + new Date() );
+
 return metadata;
 }
 
@@ -90,4 +100,23 @@
 {
 
 }
+
+@Override
+@SuppressWarnings( "unchecked" )
+ 

[Dhis2-devs] [Bug 1538175] [NEW] Metada import: section greyedfields not imported

2016-01-26 Thread Víctor García
Public bug reported:

Section greyedfields are not correctly imported when there are more than
one greyfields per dataelement.

Case: let's suppose we have a section with a dataelement that has 3 
categoryoptioncombos (a, b and c), and the options "a" and "b" are greyed. If 
we export the dataset + section, the two greyedfields are correctly exported 
(we can see the two greyedfields in the xml or json). But after importing that 
metadata into another instance, only one greyedfield is imported per 
dataelement.
It is the same if you have 3, 4 and so on greyedfields: only one is imported.

Image attached: original dataset, and dataset after import.

DHIS: 2.21 rev 20971

** Affects: dhis2
 Importance: Undecided
 Status: New

** Attachment added: "greyedfields.png"
   
https://bugs.launchpad.net/bugs/1538175/+attachment/4556842/+files/greyedfields.png

-- 
You received this bug notification because you are a member of DHIS 2
developers, which is subscribed to DHIS.
https://bugs.launchpad.net/bugs/1538175

Title:
  Metada import: section greyedfields not imported

Status in DHIS:
  New

Bug description:
  Section greyedfields are not correctly imported when there are more
  than one greyfields per dataelement.

  Case: let's suppose we have a section with a dataelement that has 3 
categoryoptioncombos (a, b and c), and the options "a" and "b" are greyed. If 
we export the dataset + section, the two greyedfields are correctly exported 
(we can see the two greyedfields in the xml or json). But after importing that 
metadata into another instance, only one greyedfield is imported per 
dataelement.
  It is the same if you have 3, 4 and so on greyedfields: only one is imported.

  Image attached: original dataset, and dataset after import.

  DHIS: 2.21 rev 20971

To manage notifications about this bug go to:
https://bugs.launchpad.net/dhis2/+bug/1538175/+subscriptions

___
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp


Re: [Dhis2-devs] bzr branch lp:dhis2

2016-01-26 Thread Knut Staring
You do not need to be a member of the core team to do this (and we don't
grant membership to the core team).

I have forwarded this email to our developer list, which you should sign up
for by joining that team.

Regards,
Knut

On Tue, Jan 26, 2016 at 3:17 PM, toseef  wrote:

> Hello,
> hope you are doing well, kindly make me join this team as I want
> to clone this project to my system...by this command "bzr branch
> lp:dhis2" its giving me permision errors. If there is anyother way to
> get dhis2 kindly help..Looking forward for your positive response..
>
> Regards
> Toseef Rehan
> --
> This message was sent from Launchpad by
> toseef (https://launchpad.net/~toseefrehan)
> using the "Contact this team's admins" link on the DHIS 2 core developers
> team page (https://launchpad.net/~dhis2-devs-core).
> For more information see
> https://help.launchpad.net/YourAccount/ContactingPeople
>



-- 
Knut Staring
Dept. of Informatics, University of Oslo
Norway: +4791880522
Skype: knutstar
http://dhis2.org
___
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp


[Dhis2-devs] [Branch ~dhis2-devs-core/dhis2/trunk] Rev 21815: minor fix

2016-01-26 Thread noreply

revno: 21815
committer: Morten Olav Hansen 
branch nick: dhis2
timestamp: Wed 2016-01-27 10:01:24 +0700
message:
  minor fix
modified:
  
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/Criteria.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-services/dhis-service-core/src/main/java/org/hisp/dhis/query/Criteria.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/Criteria.java	2016-01-04 02:27:49 +
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/Criteria.java	2016-01-27 03:01:24 +
@@ -64,14 +64,6 @@
 }
 
 Restriction restriction = (Restriction) criterion;
-
-/* Commented out for now, validation of this happens in QueryParser
-if ( !schema.haveProperty( restriction.getPath() ) )
-{
-continue;
-}
-*/
-
 this.criterions.add( restriction );
 }
 

___
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp


[Dhis2-devs] [Branch ~dhis2-devs-core/dhis2/trunk] Rev 21816: test for export of a given set of classes in metadataexportparams

2016-01-26 Thread noreply

revno: 21816
committer: Morten Olav Hansen 
branch nick: dhis2
timestamp: Wed 2016-01-27 10:17:41 +0700
message:
  test for export of a given set of classes in metadataexportparams
modified:
  
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/DefaultMetadataExportService.java
  
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/MetadataExportParams.java
  
dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata2/MetadataExportServiceTest.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-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/DefaultMetadataExportService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/DefaultMetadataExportService.java	2016-01-25 08:31:37 +
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/DefaultMetadataExportService.java	2016-01-27 03:17:41 +
@@ -66,8 +66,17 @@
 
 for ( Class klass : params.getClasses() )
 {
-Schema schema = schemaService.getDynamicSchema( klass );
-Query query = Query.from( schema );
+Query query;
+
+if ( params.hasQuery( klass ) )
+{
+query = params.getQuery( klass );
+}
+else
+{
+Schema schema = schemaService.getDynamicSchema( klass );
+query = Query.from( schema );
+}
 
 List objects = queryService.query( query );
 metadata.put( klass, objects );

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/MetadataExportParams.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/MetadataExportParams.java	2016-01-25 08:31:37 +
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/MetadataExportParams.java	2016-01-27 03:17:41 +
@@ -29,8 +29,11 @@
  */
 
 import org.hisp.dhis.common.IdentifiableObject;
+import org.hisp.dhis.query.Query;
 
+import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Map;
 import java.util.Set;
 
 /**
@@ -40,6 +43,8 @@
 {
 private Set classes = new HashSet<>();
 
+private Map queries = new HashMap<>();
+
 public MetadataExportParams()
 {
 }
@@ -53,4 +58,35 @@
 {
 this.classes = classes;
 }
+
+public MetadataExportParams addClass( Class klass )
+{
+classes.add( klass );
+return this;
+}
+
+@SuppressWarnings( "unchecked" )
+public MetadataExportParams addQuery( Query query )
+{
+if ( !query.getSchema().isIdentifiableObject() )
+{
+return this;
+}
+
+Class klass = (Class) query.getSchema().getKlass();
+classes.add( klass );
+queries.put( klass, query );
+
+return this;
+}
+
+public boolean hasQuery( Class klass )
+{
+return queries.containsKey( klass );
+}
+
+public Query getQuery( Class klass )
+{
+return queries.containsKey( klass ) ? queries.get( klass ) : null;
+}
 }

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata2/MetadataExportServiceTest.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata2/MetadataExportServiceTest.java	2016-01-25 08:31:37 +
+++ dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata2/MetadataExportServiceTest.java	2016-01-27 03:17:41 +
@@ -40,7 +40,7 @@
 import java.util.List;
 import java.util.Map;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.*;
 
 /**
  * @author Morten Olav Hansen 
@@ -91,4 +91,39 @@
 assertEquals( 1, metadata.get( DataElementGroup.class ).size() );
 assertEquals( 3, metadata.get( DataElement.class ).size() );
 }
+
+@Test
+@SuppressWarnings( "unchecked" )
+public void testMetadataExportWithCustomClasses()
+{
+DataElementGroup deg1 = createDataElementGroup( 'A' );
+DataElement de1 = createDataElement( 'A' );
+DataElement de2 = createDataElement( 'B' );
+DataElement de3 = createDataElement( 'C' );
+
+manager.save( de1 );
+manager.save( de2 );
+manager.save( de3 );
+
+User user = createUser( 'A' );
+manager.save( user );
+
+deg1.addDataElement( de1 );
+deg1.addDataElement( de2 );
+deg1.addDataElement( de3 );
+
+deg1.setUser( user );
+

[Dhis2-devs] [Branch ~dhis2-devs-core/dhis2/trunk] Rev 21817: tests for metadataexport with custom queries

2016-01-26 Thread noreply

revno: 21817
committer: Morten Olav Hansen 
branch nick: dhis2
timestamp: Wed 2016-01-27 10:37:57 +0700
message:
  tests for metadataexport with custom queries
modified:
  
dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata2/MetadataExportServiceTest.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-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata2/MetadataExportServiceTest.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata2/MetadataExportServiceTest.java	2016-01-27 03:17:41 +
+++ dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata2/MetadataExportServiceTest.java	2016-01-27 03:37:57 +
@@ -33,6 +33,10 @@
 import org.hisp.dhis.common.IdentifiableObjectManager;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementGroup;
+import org.hisp.dhis.query.Disjunction;
+import org.hisp.dhis.query.Query;
+import org.hisp.dhis.query.Restrictions;
+import org.hisp.dhis.schema.SchemaService;
 import org.hisp.dhis.user.User;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -54,6 +58,9 @@
 @Autowired
 private IdentifiableObjectManager manager;
 
+@Autowired
+private SchemaService schemaService;
+
 @Test
 public void testValidate()
 {
@@ -126,4 +133,52 @@
 
 assertEquals( 3, metadata.get( DataElement.class ).size() );
 }
+
+@Test
+@SuppressWarnings( "unchecked" )
+public void testMetadataExportWithCustomQueries()
+{
+DataElementGroup deg1 = createDataElementGroup( 'A' );
+DataElement de1 = createDataElement( 'A' );
+DataElement de2 = createDataElement( 'B' );
+DataElement de3 = createDataElement( 'C' );
+
+manager.save( de1 );
+manager.save( de2 );
+manager.save( de3 );
+
+User user = createUser( 'A' );
+manager.save( user );
+
+deg1.addDataElement( de1 );
+deg1.addDataElement( de2 );
+deg1.addDataElement( de3 );
+
+deg1.setUser( user );
+manager.save( deg1 );
+
+Query deQuery = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
+
+Disjunction disjunction = deQuery.disjunction();
+disjunction.add( Restrictions.eq( "id", de1.getUid() ) );
+disjunction.add( Restrictions.eq( "id", de2.getUid() ) );
+
+deQuery.add( disjunction );
+
+Query degQuery = Query.from( schemaService.getDynamicSchema( DataElementGroup.class ) );
+degQuery.add( Restrictions.eq( "id", "INVALID UID" ) );
+
+MetadataExportParams params = new MetadataExportParams();
+params.addQuery( deQuery );
+params.addQuery( degQuery );
+
+Map metadata = metadataExportService.getMetadata( params );
+
+assertFalse( metadata.containsKey( User.class ) );
+assertTrue( metadata.containsKey( DataElementGroup.class ) );
+assertTrue( metadata.containsKey( DataElement.class ) );
+
+assertEquals( 2, metadata.get( DataElement.class ).size() );
+assertEquals( 0, metadata.get( DataElementGroup.class ).size() );
+}
 }

___
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp


[Dhis2-devs] [Branch ~dhis2-devs-core/dhis2/trunk] Rev 21814: Don't allow resizing of dashboards if it is only shared to you with read-only permissions

2016-01-26 Thread noreply

revno: 21814
committer: Morten Olav Hansen 
branch nick: dhis2
timestamp: Tue 2016-01-26 15:55:27 +0700
message:
  Don't allow resizing of dashboards if it is only shared to you with read-only 
permissions
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardItemStore.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardService.java
  
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/hibernate/HibernateDashboardItemStore.java
  
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/impl/DefaultDashboardService.java
  
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DashboardItemController.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/dashboard/DashboardItemStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardItemStore.java	2016-01-04 02:27:49 +
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardItemStore.java	2016-01-26 08:55:27 +
@@ -50,4 +50,6 @@
 int countReportDashboardItems( Report report );
 
 int countDocumentDashboardItems( Document document );
+
+Dashboard getDashboardFromDashboardItem( DashboardItem dashboardItem );
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardService.java	2016-01-04 02:27:49 +
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardService.java	2016-01-26 08:55:27 +
@@ -74,7 +74,9 @@
 void updateDashboardItem( DashboardItem item );
 
 DashboardItem getDashboardItem( String uid );
-
+
+Dashboard getDashboardFromDashboardItem( DashboardItem dashboardItem );
+
 void deleteDashboardItem( DashboardItem item );
 
 int countMapDashboardItems( Map map );

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/hibernate/HibernateDashboardItemStore.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/hibernate/HibernateDashboardItemStore.java	2016-01-04 02:27:49 +
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/hibernate/HibernateDashboardItemStore.java	2016-01-26 08:55:27 +
@@ -31,6 +31,7 @@
 import org.hibernate.Query;
 import org.hisp.dhis.chart.Chart;
 import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
+import org.hisp.dhis.dashboard.Dashboard;
 import org.hisp.dhis.dashboard.DashboardItem;
 import org.hisp.dhis.dashboard.DashboardItemStore;
 import org.hisp.dhis.document.Document;
@@ -88,4 +89,13 @@
 
 return ((Long) query.uniqueResult()).intValue();
 }
+
+@Override
+public Dashboard getDashboardFromDashboardItem( DashboardItem dashboardItem )
+{
+Query query = getQuery( "from Dashboard d where :item in elements(d.items)" );
+query.setEntity( "item", dashboardItem );
+
+return (Dashboard) query.uniqueResult();
+}
 }

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/impl/DefaultDashboardService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/impl/DefaultDashboardService.java	2016-01-04 02:27:49 +
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/impl/DefaultDashboardService.java	2016-01-26 08:55:27 +
@@ -28,11 +28,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import static org.hisp.dhis.common.IdentifiableObjectUtils.getUids;
-
-import java.util.HashSet;
-import java.util.Set;
-
+import com.google.common.collect.Sets;
 import org.hisp.dhis.chart.Chart;
 import org.hisp.dhis.common.IdentifiableObjectManager;
 import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
@@ -54,7 +50,10 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 
-import com.google.common.collect.Sets;
+import java.util.HashSet;
+import java.util.Set;
+
+import static org.hisp.dhis.common.IdentifiableObjectUtils.getUids;
 
 /**
  * Note: The remove associations methods must be altered if caching is introduced.
@@ -306,6 +305,12 @@
 }
 
 @Override
+public Dashboard getDashboardFromDashboardItem( DashboardItem dashboardItem )
+{
+return dashboardItemStore.getDashboardFromDashboardItem( dashboardItem );
+}
+
+@Override
 public void deleteDashboardItem( DashboardItem item )
 {
 dashboardItemStore.delete( item