dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #39473
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19986: comment out de types usage in dhis14 import and mobile/sms services, will be updated later
------------------------------------------------------------
revno: 19986
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-09-04 14:11:50 +0700
message:
comment out de types usage in dhis14 import and mobile/sms services, will be updated later
modified:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/listener/DataValueSMSListener.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/listener/J2MEDataValueSMSListener.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataElementConverter.java
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/DefaultProgramService.java
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ModelMapping.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/sms/listener/DataValueSMSListener.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/listener/DataValueSMSListener.java 2015-06-23 15:59:19 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/listener/DataValueSMSListener.java 2015-09-04 07:11:50 +0000
@@ -28,22 +28,9 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
import org.apache.commons.lang3.StringUtils;
+import org.hisp.dhis.common.ValueType;
+import org.hisp.dhis.commons.util.TextUtils;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.dataelement.DataElementCategoryService;
@@ -68,11 +55,25 @@
import org.hisp.dhis.sms.incoming.SmsMessageStatus;
import org.hisp.dhis.sms.parse.ParserType;
import org.hisp.dhis.sms.parse.SMSParserException;
-import org.hisp.dhis.commons.util.TextUtils;
import org.hisp.dhis.user.User;
import org.hisp.dhis.user.UserService;
import org.springframework.transaction.annotation.Transactional;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
public class DataValueSMSListener
implements IncomingSmsListener
{
@@ -140,7 +141,7 @@
{
this.dataElementService = dataElementService;
}
-
+
@Transactional
@Override
public boolean accept( IncomingSms sms )
@@ -254,16 +255,16 @@
{
HashMap<String, String> output = new HashMap<>();
Pattern pattern = Pattern.compile( defaultPattern );
-
+
if ( !StringUtils.isBlank( smsCommand.getSeparator() ) )
{
- String x = "([^\\s|" + smsCommand.getSeparator().trim() +"]+)\\s*\\" + smsCommand.getSeparator().trim() + "\\s*([\\w ]+)\\s*(\\"
- + smsCommand.getSeparator().trim() + "|$)*\\s*";
+ String x = "([^\\s|" + smsCommand.getSeparator().trim() + "]+)\\s*\\" + smsCommand.getSeparator().trim() + "\\s*([\\w ]+)\\s*(\\"
+ + smsCommand.getSeparator().trim() + "|$)*\\s*";
pattern = Pattern.compile( x );
}
-
+
Matcher m = pattern.matcher( sms );
-
+
while ( m.find() )
{
String key = m.group( 1 );
@@ -350,18 +351,18 @@
if ( orgUnit == null && orgUnits.size() > 1 )
{
String messageListingOrgUnits = smsCommand.getMoreThanOneOrgUnitMessage();
-
+
for ( Iterator<OrganisationUnit> i = orgUnits.iterator(); i.hasNext(); )
{
OrganisationUnit o = i.next();
messageListingOrgUnits += TextUtils.SPACE + o.getName() + ":" + o.getCode();
-
+
if ( i.hasNext() )
{
messageListingOrgUnits += ",";
}
}
-
+
throw new SMSParserException( messageListingOrgUnits );
}
@@ -438,7 +439,7 @@
newDataValue = true;
}
- if ( StringUtils.equals( dv.getDataElement().getType(), DataElement.VALUE_TYPE_BOOL ) )
+ if ( ValueType.BOOLEAN == dv.getDataElement().getValueType() )
{
if ( "Y".equals( value.toUpperCase() ) || "YES".equals( value.toUpperCase() ) )
{
@@ -449,7 +450,7 @@
value = "false";
}
}
- else if ( StringUtils.equals( dv.getDataElement().getType(), DataElement.VALUE_TYPE_INT ) )
+ else if ( dv.getDataElement().getValueType().isInteger() )
{
try
{
@@ -494,10 +495,10 @@
DataValue targetDataValue = dataValueService.getDataValue( targetDataElement, period, orgunit,
dataElementCategoryService.getDefaultDataElementCategoryOptionCombo() );
-
+
int targetValue = 0;
boolean newTargetDataValue = false;
-
+
if ( targetDataValue == null )
{
targetDataValue = new DataValue();
@@ -527,7 +528,7 @@
targetDataValue.setValue( String.valueOf( targetValue ) );
targetDataValue.setLastUpdated( new java.util.Date() );
targetDataValue.setStoredBy( storedBy );
-
+
if ( newTargetDataValue )
{
dataValueService.addDataValue( targetDataValue );
@@ -581,10 +582,10 @@
}
}
}
-
+
user = u;
}
-
+
if ( user == null )
{
throw new SMSParserException( "User is not associated with any orgunit. Please contact your supervisor." );
@@ -682,7 +683,8 @@
{
DataValue dv = codesWithDataValues.get( key );
String value = dv.getValue();
- if ( StringUtils.equals( dv.getDataElement().getType(), DataElement.VALUE_TYPE_BOOL ) )
+
+ if ( ValueType.BOOLEAN == dv.getDataElement().getValueType() )
{
if ( "true".equals( value ) )
{
@@ -702,7 +704,7 @@
{
notInReport += key + ",";
}
-
+
notInReport = notInReport.substring( 0, notInReport.length() - 1 );
if ( command.getSuccessMessage() != null && !StringUtils.isEmpty( command.getSuccessMessage() ) )
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/listener/J2MEDataValueSMSListener.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/listener/J2MEDataValueSMSListener.java 2015-06-23 15:59:19 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/listener/J2MEDataValueSMSListener.java 2015-09-04 07:11:50 +0000
@@ -28,19 +28,9 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.regex.Pattern;
-
import org.apache.commons.lang3.StringUtils;
-import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.common.ValueType;
+import org.hisp.dhis.commons.util.TextUtils;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.dataelement.DataElementCategoryService;
import org.hisp.dhis.dataset.CompleteDataSetRegistration;
@@ -64,12 +54,22 @@
import org.hisp.dhis.sms.incoming.IncomingSmsListener;
import org.hisp.dhis.sms.parse.ParserType;
import org.hisp.dhis.sms.parse.SMSParserException;
-import org.hisp.dhis.commons.util.TextUtils;
import org.hisp.dhis.system.util.ValidationUtils;
import org.hisp.dhis.user.User;
import org.hisp.dhis.user.UserService;
import org.springframework.transaction.annotation.Transactional;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.regex.Pattern;
+
public class J2MEDataValueSMSListener
implements IncomingSmsListener
{
@@ -91,7 +91,7 @@
{
String message = sms.getText();
String commandString = null;
-
+
if ( message.indexOf( TextUtils.SPACE ) > 0 )
{
commandString = message.substring( 0, message.indexOf( " " ) );
@@ -226,7 +226,7 @@
newDataValue = true;
}
- if ( StringUtils.equals( dv.getDataElement().getType(), DataElement.VALUE_TYPE_BOOL ) )
+ if ( ValueType.BOOLEAN == dv.getDataElement().getValueType() )
{
if ( "Y".equals( value.toUpperCase() ) || "YES".equals( value.toUpperCase() ) )
{
@@ -279,7 +279,7 @@
if ( orgUnit == null && orgUnits.size() > 1 )
{
String messageListingOrgUnits = smsCommand.getMoreThanOneOrgUnitMessage();
-
+
for ( Iterator<OrganisationUnit> i = orgUnits.iterator(); i.hasNext(); )
{
OrganisationUnit o = i.next();
@@ -299,7 +299,7 @@
{
Collection<OrganisationUnit> orgUnits = new ArrayList<>();
Collection<User> users = userService.getUsersByPhoneNumber( sender );
-
+
for ( User u : users )
{
if ( u.getOrganisationUnits() != null )
@@ -315,7 +315,7 @@
{
OrganisationUnit orgunit = null;
User user = null;
-
+
for ( User u : userService.getUsersByPhoneNumber( sender ) )
{
OrganisationUnit ou = u.getOrganisationUnit();
@@ -388,8 +388,8 @@
else if ( dv != null )
{
String value = dv.getValue();
-
- if ( StringUtils.equals( dv.getDataElement().getType(), DataElement.VALUE_TYPE_BOOL ) )
+
+ if ( ValueType.BOOLEAN == dv.getDataElement().getValueType() )
{
if ( "true".equals( value ) )
{
@@ -400,7 +400,7 @@
value = "No";
}
}
-
+
reportBack += code.getCode() + "=" + value + " ";
}
}
@@ -411,7 +411,7 @@
{
reportBack += notInReport;
}
-
+
if ( command.getSuccessMessage() != null && !StringUtils.isEmpty( command.getSuccessMessage() ) )
{
reportBack = command.getSuccessMessage();
@@ -446,7 +446,7 @@
String pattern = "yyyy-MM-dd";
SimpleDateFormat formatter = new SimpleDateFormat( pattern );
Date date;
-
+
try
{
date = formatter.parse( periodName );
@@ -456,7 +456,7 @@
throw new IllegalArgumentException( "Couldn't make a period of type " + periodType.getName()
+ " and name " + periodName, e );
}
-
+
return periodType.createPeriod( date );
}
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataElementConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataElementConverter.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataElementConverter.java 2015-09-04 07:11:50 +0000
@@ -28,15 +28,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.hisp.dhis.dataelement.DataElementCategoryCombo.DEFAULT_CATEGORY_COMBO_NAME;
-import static org.hisp.dhis.importexport.dhis14.util.Dhis14TypeHandler.convertAggregationOperatorFromDhis14;
-import static org.hisp.dhis.importexport.dhis14.util.Dhis14TypeHandler.convertAggregationOperatorToDhis14;
-import static org.hisp.dhis.importexport.dhis14.util.Dhis14TypeHandler.convertBooleanToDhis14;
-import static org.hisp.dhis.importexport.dhis14.util.Dhis14TypeHandler.convertTypeToDhis14;
-
-import java.util.Collection;
-import java.util.Map;
-
import org.amplecode.staxwax.reader.XMLReader;
import org.amplecode.staxwax.writer.XMLWriter;
import org.hisp.dhis.dataelement.DataElement;
@@ -50,11 +41,16 @@
import org.hisp.dhis.importexport.XMLConverter;
import org.hisp.dhis.importexport.analysis.ImportAnalyser;
import org.hisp.dhis.importexport.dhis14.util.Dhis14DateUtil;
-import org.hisp.dhis.importexport.dhis14.util.Dhis14ObjectMappingUtil;
import org.hisp.dhis.importexport.dhis14.util.Dhis14ParsingUtils;
import org.hisp.dhis.importexport.importer.DataElementImporter;
import org.hisp.dhis.importexport.mapping.NameMappingUtil;
+import java.util.Collection;
+import java.util.Map;
+
+import static org.hisp.dhis.dataelement.DataElementCategoryCombo.DEFAULT_CATEGORY_COMBO_NAME;
+import static org.hisp.dhis.importexport.dhis14.util.Dhis14TypeHandler.*;
+
/**
* @author Lars Helge Overland
* @version $Id: DataElementConverter.java 6455 2008-11-24 08:59:37Z larshelg $
@@ -173,9 +169,9 @@
/**
* Constructor for read operations.
- *
+ *
* @param importObjectService the importObjectService to use.
- * @param dataElementService the dataElementService to use.
+ * @param dataElementService the dataElementService to use.
*/
public DataElementConverter( ImportObjectService importObjectService, DataElementService dataElementService,
DataElementCategoryService categoryService, ImportAnalyser importAnalyser )
@@ -214,7 +210,7 @@
writer.writeElement( FIELD_DOS, object.getShortName().replaceAll( "[^a-zA-Z0-9]", "" ) );
writer.writeElement( FIELD_DATALEMENTPROMPT, "" );
writer.writeElement( FIELD_META, String.valueOf( 0 ) );
- writer.writeElement( FIELD_DATA_TYPE, convertTypeToDhis14( object.getType() ) );
+ // writer.writeElement( FIELD_DATA_TYPE, convertTypeToDhis14( object.getType() ) );
writer.writeElement( FIELD_PERIOD_TYPE, String.valueOf( 1 ) );
writer.writeElement( FIELD_VALID_FROM, String.valueOf( VALID_FROM ) );
writer.writeElement( FIELD_VALID_TO, String.valueOf( VALID_TO ) );
@@ -276,14 +272,12 @@
element.setDescription( Dhis14ParsingUtils.removeNewLine( values.get( FIELD_DESCRIPTION ) ) );
element.setDomainType( DataElementDomain.AGGREGATE );
element.setZeroIsSignificant( false );
- element.setType( Dhis14ObjectMappingUtil.getDataElementTypeMap().get(
- Integer.parseInt( values.get( FIELD_DATA_TYPE ) ) ) );
- element
- .setAggregationOperator( convertAggregationOperatorFromDhis14( values.get( FIELD_AGGREGATION_OPERATOR ) ) );
+ // element.setType( Dhis14ObjectMappingUtil.getDataElementTypeMap().get(Integer.parseInt( values.get( FIELD_DATA_TYPE ) ) ) );
+ element.setAggregationOperator( convertAggregationOperatorFromDhis14( values.get( FIELD_AGGREGATION_OPERATOR ) ) );
element.setLastUpdated( Dhis14DateUtil.getDate( values.get( FIELD_LAST_UPDATED ) ) );
if ( values.get( FIELD_CALCULATED ).equals( "0" ) ) // Ignore calculated
- // data elements
+ // data elements
{
importObject( element, params );
}
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2015-09-03 08:15:09 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2015-09-04 07:11:50 +0000
@@ -503,7 +503,7 @@
String value = dataElement1.getValue();
- if ( dataElement.getType().equalsIgnoreCase( "date" ) && !value.trim().equals( "" ) )
+ if ( ValueType.DATE == dataElement.getValueType() && !value.trim().equals( "" ) )
{
value = PeriodUtil.convertDateFormat( value );
}
@@ -545,8 +545,7 @@
String value = dataElement1.getValue();
if ( value != null )
{
-
- if ( dataElement.getType().equalsIgnoreCase( "date" ) && !value.trim().equals( "" ) )
+ if ( ValueType.DATE == dataElement.getValueType() && !value.trim().equals( "" ) )
{
value = PeriodUtil.convertDateFormat( value );
}
@@ -1055,12 +1054,12 @@
}
mobileDataElement.setName( dataElementName );
- mobileDataElement.setType( programStageDataElement.getDataElement().getType() );
+ // mobileDataElement.setType( programStageDataElement.getDataElement().getType() );
// problem
mobileDataElement.setCompulsory( programStageDataElement.isCompulsory() );
- mobileDataElement.setNumberType( programStageDataElement.getDataElement().getNumberType() );
+ // mobileDataElement.setNumberType( programStageDataElement.getDataElement().getNumberType() );
// Value
TrackedEntityDataValue patientDataValue = dataValueService.getTrackedEntityDataValue( programStageInstance,
@@ -1069,8 +1068,7 @@
if ( patientDataValue != null )
{
// Convert to standard date format before send to client
- if ( programStageDataElement.getDataElement().getType().equalsIgnoreCase( "date" )
- && !patientDataValue.equals( "" ) )
+ if ( ValueType.DATE == programStageDataElement.getDataElement().getValueType() && !patientDataValue.equals( "" ) )
{
mobileDataElement.setValue( PeriodUtil.convertDateFormat( patientDataValue.getValue() ) );
}
@@ -1302,19 +1300,18 @@
org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStageDataElement mobileDataElement = new org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStageDataElement();
mobileDataElement.setId( programStageDataElement.getDataElement().getId() );
mobileDataElement.setName( programStageDataElement.getDataElement().getName() );
- mobileDataElement.setType( programStageDataElement.getDataElement().getType() );
+ // mobileDataElement.setType( programStageDataElement.getDataElement().getType() );
// problem
mobileDataElement.setCompulsory( programStageDataElement.isCompulsory() );
- mobileDataElement.setNumberType( programStageDataElement.getDataElement().getNumberType() );
+ // mobileDataElement.setNumberType( programStageDataElement.getDataElement().getNumberType() );
mobileDataElement.setValue( "" );
if ( programStageDataElement.getDataElement().getOptionSet() != null )
{
- mobileDataElement
- .setOptionSet( ModelMapping.getOptionSet( programStageDataElement.getDataElement() ) );
+ mobileDataElement.setOptionSet( ModelMapping.getOptionSet( programStageDataElement.getDataElement() ) );
}
else
{
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/DefaultProgramService.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/DefaultProgramService.java 2015-09-03 08:15:09 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/DefaultProgramService.java 2015-09-04 07:11:50 +0000
@@ -252,7 +252,7 @@
org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStageDataElement de = ModelMapping.getDataElementLWUIT( dataElement );
de.setCompulsory( programStageDataElement.isCompulsory() );
- de.setNumberType( programStageDataElement.getDataElement().getNumberType() );
+ // de.setNumberType( programStageDataElement.getDataElement().getNumberType() );
des.add( de );
}
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ModelMapping.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ModelMapping.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ModelMapping.java 2015-09-04 07:11:50 +0000
@@ -28,17 +28,17 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.ArrayList;
-import java.util.List;
-
import org.hisp.dhis.api.mobile.model.DataElement;
+import org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStageDataElement;
import org.hisp.dhis.api.mobile.model.Model;
import org.hisp.dhis.api.mobile.model.ModelList;
import org.hisp.dhis.api.mobile.model.OptionSet;
-import org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStageDataElement;
import org.hisp.dhis.dataelement.DataElementCategoryCombo;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import java.util.ArrayList;
+import java.util.List;
+
public class ModelMapping
{
public static DataElement getDataElement( org.hisp.dhis.dataelement.DataElement dataElement )
@@ -46,7 +46,7 @@
DataElement de = new DataElement();
de.setId( dataElement.getId() );
de.setName( dataElement.getFormNameFallback() );
- de.setType( dataElement.getType() );
+ // de.setType( dataElement.getType() );
de.setCategoryOptionCombos( getCategoryOptionCombos( dataElement ) );
@@ -54,7 +54,8 @@
if ( dataElement.getOptionSet() != null && dataElement.getOptionSet().getOptions().size() <= 50 )
{
de.setOptionSet( getOptionSet( dataElement ) );
- }
+ }
+
return de;
}
@@ -63,7 +64,7 @@
ProgramStageDataElement de = new ProgramStageDataElement();
de.setId( dataElement.getId() );
de.setName( dataElement.getFormNameFallback() );
- de.setType( dataElement.getType() );
+ // de.setType( dataElement.getType() );
de.setCategoryOptionCombos( getCategoryOptionCombos( dataElement ) );
@@ -71,8 +72,8 @@
if ( dataElement.getOptionSet() != null && dataElement.getOptionSet().getOptions().size() <= 50 )
{
de.setOptionSet( getOptionSet( dataElement ) );
- }
-
+ }
+
return de;
}