dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #41723
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21276: minor change in idSchemes, support new scheme type ATTRIBUTE:<UID>
------------------------------------------------------------
revno: 21276
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-12-03 09:06:56 +0700
message:
minor change in idSchemes, support new scheme type ATTRIBUTE:<UID>
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableProperty.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/IdSchemes.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SystemController.java
dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/datavalue/ExportDataValueAction.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/common/IdentifiableProperty.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableProperty.java 2015-02-16 08:37:44 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableProperty.java 2015-12-03 02:06:56 +0000
@@ -33,5 +33,5 @@
*/
public enum IdentifiableProperty
{
- ID, UID, UUID, NAME, CODE
+ ID, UID, UUID, NAME, CODE, ATTRIBUTE
}
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/IdSchemes.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/IdSchemes.java 2015-02-17 06:00:52 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/IdSchemes.java 2015-12-03 02:06:56 +0000
@@ -28,8 +28,10 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import com.google.common.base.MoreObjects;
import org.hisp.dhis.common.IdentifiableObject;
import org.hisp.dhis.common.IdentifiableProperty;
+import org.springframework.util.StringUtils;
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -38,83 +40,137 @@
{
private IdentifiableProperty idScheme;
+ private String idSchemeAttribute;
+
private IdentifiableProperty dataElementIdScheme = IdentifiableProperty.UID;
+ private String dataElementIdSchemeAttribute;
+
private IdentifiableProperty categoryOptionComboIdScheme = IdentifiableProperty.UID;
+ private String categoryOptionComboIdSchemeAttribute;
+
private IdentifiableProperty orgUnitIdScheme = IdentifiableProperty.UID;
+ private String orgUnitIdSchemeAttribute;
+
private IdentifiableProperty programIdScheme = IdentifiableProperty.UID;
+ private String programIdSchemeAttribute;
+
private IdentifiableProperty programStageIdScheme = IdentifiableProperty.UID;
+ private String programStageIdSchemeAttribute;
+
public IdSchemes()
{
}
+ public IdentifiableProperty getScheme( IdentifiableProperty identifiableProperty )
+ {
+ return idScheme != null ? idScheme : identifiableProperty;
+ }
+
public IdentifiableProperty getIdScheme()
{
return idScheme;
}
- public IdentifiableProperty getIdentifiableProperty( IdentifiableProperty identifiableProperty )
+ public void setIdScheme( String idScheme )
{
- return idScheme != null ? idScheme : identifiableProperty;
- }
+ if ( isAttribute( idScheme ) )
+ {
+ this.idScheme = IdentifiableProperty.ATTRIBUTE;
+ this.idSchemeAttribute = idScheme.substring( 10 );
+ return;
+ }
- public void setIdScheme( IdentifiableProperty idScheme )
- {
- this.idScheme = idScheme;
+ this.idScheme = IdentifiableProperty.valueOf( idScheme.toUpperCase() );
}
public IdentifiableProperty getDataElementIdScheme()
{
- return getIdentifiableProperty( dataElementIdScheme );
+ return getScheme( dataElementIdScheme );
}
- public void setDataElementIdScheme( IdentifiableProperty dataElementIdScheme )
+ public void setDataElementIdScheme( String idScheme )
{
- this.dataElementIdScheme = dataElementIdScheme;
+ if ( isAttribute( idScheme ) )
+ {
+ this.dataElementIdScheme = IdentifiableProperty.ATTRIBUTE;
+ this.dataElementIdSchemeAttribute = idScheme.substring( 10 );
+ return;
+ }
+
+ this.dataElementIdScheme = IdentifiableProperty.valueOf( idScheme.toUpperCase() );
}
public IdentifiableProperty getCategoryOptionComboIdScheme()
{
- return getIdentifiableProperty( categoryOptionComboIdScheme );
+ return getScheme( categoryOptionComboIdScheme );
}
- public void setCategoryOptionComboIdScheme( IdentifiableProperty categoryOptionComboIdScheme )
+ public void setCategoryOptionComboIdScheme( String idScheme )
{
- this.categoryOptionComboIdScheme = categoryOptionComboIdScheme;
+ if ( isAttribute( idScheme ) )
+ {
+ this.categoryOptionComboIdScheme = IdentifiableProperty.ATTRIBUTE;
+ this.categoryOptionComboIdSchemeAttribute = idScheme.substring( 10 );
+ return;
+ }
+
+ this.categoryOptionComboIdScheme = IdentifiableProperty.valueOf( idScheme.toUpperCase() );
}
public IdentifiableProperty getOrgUnitIdScheme()
{
- return getIdentifiableProperty( orgUnitIdScheme );
+ return getScheme( orgUnitIdScheme );
}
- public void setOrgUnitIdScheme( IdentifiableProperty orgUnitIdScheme )
+ public void setOrgUnitIdScheme( String idScheme )
{
- this.orgUnitIdScheme = orgUnitIdScheme;
+ if ( isAttribute( idScheme ) )
+ {
+ this.orgUnitIdScheme = IdentifiableProperty.ATTRIBUTE;
+ this.orgUnitIdSchemeAttribute = idScheme.substring( 10 );
+ return;
+ }
+
+ this.orgUnitIdScheme = IdentifiableProperty.valueOf( idScheme.toUpperCase() );
}
public IdentifiableProperty getProgramIdScheme()
{
- return getIdentifiableProperty( programIdScheme );
+ return getScheme( programIdScheme );
}
- public void setProgramIdScheme( IdentifiableProperty programIdScheme )
+ public void setProgramIdScheme( String idScheme )
{
- this.programIdScheme = programIdScheme;
+ if ( isAttribute( idScheme ) )
+ {
+ this.programIdScheme = IdentifiableProperty.ATTRIBUTE;
+ this.programIdSchemeAttribute = idScheme.substring( 10 );
+ return;
+ }
+
+ this.programIdScheme = IdentifiableProperty.valueOf( idScheme.toUpperCase() );
}
public IdentifiableProperty getProgramStageIdScheme()
{
- return getIdentifiableProperty( programStageIdScheme );
+ return getScheme( programStageIdScheme );
}
- public void setProgramStageIdScheme( IdentifiableProperty programStageIdScheme )
+ public void setProgramStageIdScheme( String idScheme )
{
- this.programStageIdScheme = programStageIdScheme;
+ if ( isAttribute( idScheme ) )
+ {
+ this.programStageIdScheme = IdentifiableProperty.ATTRIBUTE;
+ this.programStageIdSchemeAttribute = idScheme.substring( 10 );
+ return;
+ }
+
+ this.programStageIdScheme = IdentifiableProperty.valueOf( idScheme.toUpperCase() );
}
public static String getValue( String uid, String code, IdentifiableProperty identifiableProperty )
@@ -123,6 +179,7 @@
return idScheme ? uid : code;
}
+
public static String getValue( IdentifiableObject identifiableObject, IdentifiableProperty identifiableProperty )
{
boolean idScheme = IdentifiableProperty.ID.equals( identifiableProperty ) || IdentifiableProperty.UID.equals( identifiableProperty );
@@ -142,4 +199,28 @@
return null;
}
+
+ public static boolean isAttribute( String str )
+ {
+ return !StringUtils.isEmpty( str ) && str.toUpperCase().startsWith( "ATTRIBUTE:" ) && str.length() == 21;
+ }
+
+ @Override
+ public String toString()
+ {
+ return MoreObjects.toStringHelper( this )
+ .add( "idScheme", idScheme )
+ .add( "idSchemeAttribute", idSchemeAttribute )
+ .add( "dataElementIdScheme", dataElementIdScheme )
+ .add( "dataElementIdSchemeAttribute", dataElementIdSchemeAttribute )
+ .add( "categoryOptionComboIdScheme", categoryOptionComboIdScheme )
+ .add( "categoryOptionComboIdSchemeAttribute", categoryOptionComboIdSchemeAttribute )
+ .add( "orgUnitIdScheme", orgUnitIdScheme )
+ .add( "orgUnitIdSchemeAttribute", orgUnitIdSchemeAttribute )
+ .add( "programIdScheme", programIdScheme )
+ .add( "programIdSchemeAttribute", programIdSchemeAttribute )
+ .add( "programStageIdScheme", programStageIdScheme )
+ .add( "programStageIdSchemeAttribute", programStageIdSchemeAttribute )
+ .toString();
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SystemController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SystemController.java 2015-10-20 03:53:50 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SystemController.java 2015-12-03 02:06:56 +0000
@@ -31,6 +31,7 @@
import org.hisp.dhis.common.CodeGenerator;
import org.hisp.dhis.dataintegrity.DataIntegrityReport;
import org.hisp.dhis.dataintegrity.FlattenedDataIntegrityReport;
+import org.hisp.dhis.dxf2.common.IdSchemes;
import org.hisp.dhis.dxf2.metadata.ImportSummary;
import org.hisp.dhis.dxf2.render.RenderService;
import org.hisp.dhis.node.exception.InvalidTypeException;
@@ -201,6 +202,13 @@
return "pong";
}
+ @RequestMapping( value = "/scheme", method = RequestMethod.GET, produces = "text/plain" )
+ public @ResponseBody String scheme( IdSchemes idSchemes )
+ {
+ System.err.println( "id: " + idSchemes );
+ return "pong";
+ }
+
@RequestMapping( value = "/flags", method = RequestMethod.GET, produces = { "application/json" } )
public @ResponseBody List<StyleObject> getFlags()
{
=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/datavalue/ExportDataValueAction.java'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/datavalue/ExportDataValueAction.java 2015-10-08 13:50:01 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/datavalue/ExportDataValueAction.java 2015-12-03 02:06:56 +0000
@@ -1,6 +1,24 @@
package org.hisp.dhis.importexport.action.datavalue;
+import com.opensymphony.xwork2.Action;
+import org.apache.struts2.ServletActionContext;
+import org.hisp.dhis.common.IdentifiableObjectUtils;
+import org.hisp.dhis.common.IdentifiableProperty;
+import org.hisp.dhis.dxf2.common.IdSchemes;
+import org.hisp.dhis.dxf2.datavalueset.DataExportParams;
+import org.hisp.dhis.dxf2.datavalueset.DataValueSetService;
+import org.hisp.dhis.oust.manager.SelectionTreeManager;
+import org.hisp.dhis.util.ContextUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.OutputStreamWriter;
+import java.util.HashSet;
+import java.util.Set;
+
import static org.hisp.dhis.system.util.CodecUtils.filenameEncode;
+import static org.hisp.dhis.system.util.DateUtils.getMediumDate;
+import static org.hisp.dhis.util.ContextUtils.*;
/*
* Copyright (c) 2004-2015, University of Oslo
@@ -30,30 +48,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.hisp.dhis.system.util.DateUtils.getMediumDate;
-import static org.hisp.dhis.util.ContextUtils.CONTENT_TYPE_CSV;
-import static org.hisp.dhis.util.ContextUtils.CONTENT_TYPE_JSON;
-import static org.hisp.dhis.util.ContextUtils.CONTENT_TYPE_XML;
-import static org.hisp.dhis.util.ContextUtils.getZipOut;
-
-import java.io.OutputStreamWriter;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.struts2.ServletActionContext;
-import org.hisp.dhis.common.IdentifiableObjectUtils;
-import org.hisp.dhis.common.IdentifiableProperty;
-import org.hisp.dhis.dxf2.common.IdSchemes;
-import org.hisp.dhis.dxf2.datavalueset.DataExportParams;
-import org.hisp.dhis.dxf2.datavalueset.DataValueSetService;
-import org.hisp.dhis.oust.manager.SelectionTreeManager;
-import org.hisp.dhis.util.ContextUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import com.opensymphony.xwork2.Action;
-
/**
* @author Lars Helge Overland
*/
@@ -141,17 +135,17 @@
//TODO re-implement using Web API
IdSchemes idSchemes = new IdSchemes();
- idSchemes.setDataElementIdScheme( dataElementIdScheme );
- idSchemes.setOrgUnitIdScheme( orgUnitIdScheme );
- idSchemes.setCategoryOptionComboIdScheme( categoryOptionComboIdScheme );
+ idSchemes.setDataElementIdScheme( dataElementIdScheme.toString() );
+ idSchemes.setOrgUnitIdScheme( orgUnitIdScheme.toString() );
+ idSchemes.setCategoryOptionComboIdScheme( categoryOptionComboIdScheme.toString() );
Set<String> orgUnits = new HashSet<>( IdentifiableObjectUtils.getUids( selectionTreeManager.getSelectedOrganisationUnits() ) );
HttpServletResponse response = ServletActionContext.getResponse();
- DataExportParams params = dataValueSetService.getFromUrl( selectedDataSets, null,
+ DataExportParams params = dataValueSetService.getFromUrl( selectedDataSets, null,
getMediumDate( startDate ), getMediumDate( endDate ), orgUnits, true, null, null, idSchemes );
-
+
if ( FORMAT_CSV.equals( exportFormat ) )
{
ContextUtils.configureResponse( response, CONTENT_TYPE_CSV, true, getFileName( EXTENSION_CSV_ZIP ), true );