dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #43550
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 22076: searchScope property for trackedEntityAttribute
------------------------------------------------------------
revno: 22076
committer: Abyot Asalefew Gizaw <abyot@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2016-02-29 12:22:40 +0100
message:
searchScope property for trackedEntityAttribute
added:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeSearchScope.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttribute.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/startup/TableAlteror.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntityAttribute.hbm.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/AddAttributeAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/UpdateAttributeAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/org/hisp/dhis/trackedentity/i18n_module.properties
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addAttributeForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/attribute.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateAttibuteForm.vm
--
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/trackedentity/TrackedEntityAttribute.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttribute.java 2016-02-11 09:27:02 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttribute.java 2016-02-29 11:22:40 +0000
@@ -78,13 +78,15 @@
private Boolean confidential = false;
- private Boolean unique = false;
+ private Boolean unique = false;
// For Local ID type
private Boolean orgunitScope = false;
private Boolean programScope = false;
+
+ private TrackedEntityAttributeSearchScope searchScope;
// -------------------------------------------------------------------------
// Constructors
@@ -394,6 +396,19 @@
this.confidential = confidential;
}
+ @JsonProperty
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ public TrackedEntityAttributeSearchScope getSearchScope()
+ {
+ return searchScope;
+ }
+
+ public void setSearchScope( TrackedEntityAttributeSearchScope searchScope )
+ {
+ this.searchScope = searchScope;
+ }
+
@Override
public void mergeWith( IdentifiableObject other, MergeMode mergeMode )
{
@@ -417,6 +432,7 @@
unique = trackedEntityAttribute.isUnique();
orgunitScope = trackedEntityAttribute.getOrgunitScope();
programScope = trackedEntityAttribute.getProgramScope();
+ searchScope = trackedEntityAttribute.getSearchScope();
optionSet = trackedEntityAttribute.getOptionSet();
}
else if ( mergeMode.isMerge() )
@@ -430,9 +446,10 @@
sortOrderInVisitSchedule = trackedEntityAttribute.getSortOrderInVisitSchedule() == null ? sortOrderInVisitSchedule : trackedEntityAttribute.getSortOrderInVisitSchedule();
displayInListNoProgram = trackedEntityAttribute.getDisplayInListNoProgram() == null ? displayInListNoProgram : trackedEntityAttribute.getDisplayInListNoProgram();
sortOrderInListNoProgram = trackedEntityAttribute.getSortOrderInListNoProgram() == null ? sortOrderInListNoProgram : trackedEntityAttribute.getSortOrderInListNoProgram();
- unique = trackedEntityAttribute.isUnique() == null ? unique : trackedEntityAttribute.isUnique();
+ unique = trackedEntityAttribute.isUnique() == null ? unique : trackedEntityAttribute.isUnique();
orgunitScope = trackedEntityAttribute.getOrgunitScope() == null ? orgunitScope : trackedEntityAttribute.getOrgunitScope();
programScope = trackedEntityAttribute.getProgramScope() == null ? programScope : trackedEntityAttribute.getProgramScope();
+ searchScope = trackedEntityAttribute.getSearchScope() == null ? searchScope : trackedEntityAttribute.getSearchScope();
optionSet = trackedEntityAttribute.getOptionSet() == null ? optionSet : trackedEntityAttribute.getOptionSet();
}
}
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeSearchScope.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeSearchScope.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeSearchScope.java 2016-02-29 11:22:40 +0000
@@ -0,0 +1,65 @@
+package org.hisp.dhis.trackedentity;
+
+/*
+ * Copyright (c) 2004-2016, 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.
+ */
+
+/**
+ * @author Abyot Asalefew Gizaw <abyot@xxxxxxxxx>
+ *
+ */
+public enum TrackedEntityAttributeSearchScope
+{
+
+ NOT_SEARCHABLE( "not_searchable" ), OWN_OUS( "own_organisations" ), SEARCH_OUS( "search_organisations" );
+
+ private final String value;
+
+ private TrackedEntityAttributeSearchScope( String value )
+ {
+ this.value = value;
+ }
+
+ public static TrackedEntityAttributeSearchScope fromValue( String value )
+ {
+ for ( TrackedEntityAttributeSearchScope trackedEntityAttributeSearchScope : TrackedEntityAttributeSearchScope
+ .values() )
+ {
+ if ( trackedEntityAttributeSearchScope.value.equalsIgnoreCase( value ) )
+ {
+ return trackedEntityAttributeSearchScope;
+ }
+ }
+
+ return null;
+ }
+
+ public String getValue()
+ {
+ return value;
+ }
+}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/startup/TableAlteror.java 2016-02-24 04:25:21 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/startup/TableAlteror.java 2016-02-29 11:22:40 +0000
@@ -256,7 +256,10 @@
executeSql( "update trackedentityattribute set aggregationype='AVERAGE' where aggregationtype is null" );
executeSql( "UPDATE trackedentityattribute SET valuetype='string' WHERE valuetype='localId';" );
- executeSql( "UPDATE trackedentityattribute SET valuetype='number' WHERE valuetype='age'" );
+ executeSql( "UPDATE trackedentityattribute SET valuetype='number' WHERE valuetype='age'" );
+
+ executeSql( "update trackedentityattribute set searchscope='NOT_SEARCHABLE' where confidential=true" );
+ executeSql( "update trackedentityattribute set searchscope='SEARCH_OUS' where searchscope is null" );
executeSql( "DROP TABLE orgunitgroupprograms" );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntityAttribute.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntityAttribute.hbm.xml 2015-11-23 06:52:49 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntityAttribute.hbm.xml 2016-02-29 11:22:40 +0000
@@ -67,6 +67,14 @@
<property name="orgunitScope" />
<property name="programScope" />
+
+ <property name="searchScope" length="40" column="searchscope">
+ <type name="org.hibernate.type.EnumType">
+ <param name="enumClass">org.hisp.dhis.trackedentity.TrackedEntityAttributeSearchScope</param>
+ <param name="useNamed">true</param>
+ <param name="type">12</param>
+ </type>
+ </property>
<!-- Access properties -->
<many-to-one name="user" class="org.hisp.dhis.user.User"
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/AddAttributeAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/AddAttributeAction.java 2016-01-06 12:12:35 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/AddAttributeAction.java 2016-02-29 11:22:40 +0000
@@ -9,6 +9,7 @@
import org.hisp.dhis.option.OptionService;
import org.hisp.dhis.option.OptionSet;
import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
+import org.hisp.dhis.trackedentity.TrackedEntityAttributeSearchScope;
import org.hisp.dhis.trackedentity.TrackedEntityAttributeService;
import org.hisp.dhis.trackedentity.TrackedEntityService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -189,6 +190,13 @@
this.jsonAttributeValues = jsonAttributeValues;
}
+ private TrackedEntityAttributeSearchScope searchScope;
+
+ public void setSearchScope( TrackedEntityAttributeSearchScope searchScope )
+ {
+ this.searchScope = searchScope;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -212,6 +220,7 @@
trackedEntityAttribute.setExpression( expression );
trackedEntityAttribute.setDisplayOnVisitSchedule( false );
trackedEntityAttribute.setOptionSet( optionSet );
+ trackedEntityAttribute.setSearchScope( searchScope );
unique = unique != null;
trackedEntityAttribute.setUnique( unique );
@@ -222,6 +231,11 @@
confidential = confidential != null;
trackedEntityAttribute.setConfidential( confidential );
+ if ( confidential )
+ {
+ trackedEntityAttribute.setSearchScope( TrackedEntityAttributeSearchScope.NOT_SEARCHABLE );
+ }
+
if ( unique )
{
boolean orgunitScope = false;
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/UpdateAttributeAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/UpdateAttributeAction.java 2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/UpdateAttributeAction.java 2016-02-29 11:22:40 +0000
@@ -37,6 +37,7 @@
import org.hisp.dhis.option.OptionService;
import org.hisp.dhis.option.OptionSet;
import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
+import org.hisp.dhis.trackedentity.TrackedEntityAttributeSearchScope;
import org.hisp.dhis.trackedentity.TrackedEntityAttributeService;
import org.hisp.dhis.trackedentity.TrackedEntityService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -188,6 +189,13 @@
{
this.jsonAttributeValues = jsonAttributeValues;
}
+
+ private TrackedEntityAttributeSearchScope searchScope;
+
+ public void setSearchScope( TrackedEntityAttributeSearchScope searchScope )
+ {
+ this.searchScope = searchScope;
+ }
// -------------------------------------------------------------------------
// Action implementation
@@ -212,6 +220,7 @@
trackedEntityAttribute.setExpression( expression );
trackedEntityAttribute.setDisplayOnVisitSchedule( false );
trackedEntityAttribute.setOptionSet( optionSet );
+ trackedEntityAttribute.setSearchScope( searchScope );
unique = unique != null;
trackedEntityAttribute.setUnique( unique );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/org/hisp/dhis/trackedentity/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/org/hisp/dhis/trackedentity/i18n_module.properties 2016-02-26 15:26:07 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/org/hisp/dhis/trackedentity/i18n_module.properties 2016-02-29 11:22:40 +0000
@@ -546,4 +546,8 @@
data_approval_workflow=Data approval workflow
display_front_page_list=Display front page list
encryption_not_available=Encryption is not configured
-not_available_for_search_and_analytics=Not available for search and analytics
\ No newline at end of file
+not_available_for_search_and_analytics=Not available for search and analytics
+search_scope=Search scope
+not_searchable=Not searchable
+within_own_ous=Within data capture organisations
+within_search_ous=Within search organisations
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addAttributeForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addAttributeForm.vm 2016-01-08 16:27:29 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addAttributeForm.vm 2016-02-29 11:22:40 +0000
@@ -79,7 +79,7 @@
<td><label for="confidential">$i18n.getString( "confidential" ) <br /><span class="tipText">($i18n.getString( "not_available_for_search_and_analytics" ))</span></label></td>
<td>
#if( $encryptionAvailable )
- <input type='checkbox' id="confidential" name="confidential" value='true'>
+ <input type='checkbox' id="confidential" name="confidential" value='true' onchange='applyConfidentialEffect();'>
#else
<p style="max-width: 312px">
<b>$i18n.getString( "encryption_not_available" )</b>
@@ -90,6 +90,18 @@
</tr>
<tr>
+ <td><label for="searchScope">$i18n.getString( "search_scope" ) <br /></label></td>
+ <td>
+ <select id="searchScope" name="searchScope" >
+ <option value='SEARCH_OUS'>$i18n.getString('within_search_ous')</option>
+ <option value='OWN_OUS'>$i18n.getString('within_own_ous')</option>
+ <option value='NOT_SEARCHABLE'>$i18n.getString('not_searchable')</option>
+ </select>
+ </td>
+ <td></td>
+ </tr>
+
+ <tr>
<td><label for="optionSetId">$i18n.getString( "option_set" )</label></td>
<td><select id="optionSetId" name="optionSetId" onchange="optionSetChanged()">
<option value="0">[$i18n.getString('please_select')]</option>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/attribute.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/attribute.js 2015-10-19 19:21:51 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/attribute.js 2016-02-29 11:22:40 +0000
@@ -6,6 +6,8 @@
typeOnChange();
optionSetChanged();
+ applyConfidentialEffect();
+
});
// -----------------------------------------------------------------------------
@@ -128,3 +130,13 @@
jQuery('#valueType [value=USERNAME]').show();
}
}
+
+function applyConfidentialEffect() {
+ if( $('#confidential').attr('checked') == "checked" ) {
+ $('#searchScope').find('option[value="NOT_SEARCHABLE"]').prop('selected', true);
+ $('#searchScope').prop('disabled', true);
+ }
+ else {
+ $('#searchScope').prop('disabled', false);
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateAttibuteForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateAttibuteForm.vm 2016-01-08 16:27:29 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateAttibuteForm.vm 2016-02-29 11:22:40 +0000
@@ -76,7 +76,7 @@
<td><label for="confidential">$i18n.getString( "confidential" ) <br /><span class="tipText">($i18n.getString( "not_available_for_search_and_analytics" ))</span></label></td>
<td>
#if( $encryptionAvailable )
- <input type='checkbox' id="confidential" name="confidential" value='true' #if( $attribute.confidential ) checked #end disabled="disabled">
+ <input type='checkbox' id="confidential" name="confidential" value='true' #if( $attribute.confidential ) checked #end disabled="disabled" onchange='applyConfidentialEffect();'>
#else
<p style="max-width: 312px">
<b>$i18n.getString( "encryption_not_available" )</b>
@@ -85,7 +85,19 @@
</td>
<td></td>
</tr>
-
+
+ <tr>
+ <td><label for="searchScope">$i18n.getString( "search_scope" ) <br /></label></td>
+ <td>
+ <select id="searchScope" name="searchScope" >
+ <option value='SEARCH_OUS' #if( $attribute.searchScope=='SEARCH_OUS' ) selected #end>$i18n.getString('within_search_ous')</option>
+ <option value='OWN_OUS' #if( $attribute.searchScope=='OWN_OUS' ) selected #end>$i18n.getString('within_own_ous')</option>
+ <option value='NOT_SEARCHABLE' #if( $attribute.searchScope=='NOT_SEARCHABLE' ) selected #end>$i18n.getString('not_searchable')</option>
+ </select>
+ </td>
+ <td></td>
+ </tr>
+
<tr>
<td><label for="optionSetId">$i18n.getString( "option_set" )</label></td>
<td><select id="optionSetId" name="optionSetId" onchange="optionSetChanged()">