dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #22626
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10927: fix bug Unicode sms, SMS command edit window for alert message, clean code
------------------------------------------------------------
revno: 10927
committer: Lai <lai.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-05-22 14:06:36 +0700
message:
fix bug Unicode sms, SMS command edit window for alert message, clean code
modified:
dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/SmsSender.java
dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SmsLibService.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/smscommand/EditSMSCommandForm.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/smscommand/SMSCommandAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/smscommand/edit-sms-command.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-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/SmsSender.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/SmsSender.java 2013-05-21 10:16:13 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/SmsSender.java 2013-05-22 07:06:36 +0000
@@ -82,7 +82,7 @@
/**
* Note this methods is invoked asynchronously.
*/
- // @Async
+ //@Async
@Override
public String sendMessage( String subject, String text, User sender, Set<User> users, boolean forceSend )
{
@@ -144,6 +144,7 @@
// -------------------------------------------------------------------------
private String createMessage( String subject, String text, User sender )
+ //private String createMessage( String subject, String text, User sender, boolean isUnicode )
{
String name = "unknown";
@@ -187,6 +188,7 @@
}
private String sendMessage( String text, Set<String> recipients, String gateWayId )
+ //private String sendMessage( String text, Set<String> recipients, String gateWayId, boolean isUnicode )
{
String message = null;
OutboundSms sms = new OutboundSms();
=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SmsLibService.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SmsLibService.java 2013-05-15 04:10:55 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SmsLibService.java 2013-05-22 07:06:36 +0000
@@ -48,6 +48,7 @@
import org.smslib.OutboundMessage;
import org.smslib.SMSLibException;
import org.smslib.Service;
+import org.smslib.Message.MessageEncodings;
import org.smslib.Service.ServiceStatus;
import java.io.IOException;
@@ -145,6 +146,8 @@
}
OutboundMessage outboundMessage = new OutboundMessage( recipient, sms.getMessage() );
+
+ outboundMessage.setEncoding( MessageEncodings.ENCUCS2 );
String longNumber = config.getLongNumber();
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/smscommand/EditSMSCommandForm.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/smscommand/EditSMSCommandForm.java 2013-03-13 10:11:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/smscommand/EditSMSCommandForm.java 2013-05-22 07:06:36 +0000
@@ -42,21 +42,53 @@
import org.hisp.dhis.smscommand.SMSCode;
import org.hisp.dhis.smscommand.SMSCommand;
import org.hisp.dhis.smscommand.SMSCommandService;
+import org.hisp.dhis.user.UserGroupService;
import com.opensymphony.xwork2.Action;
public class EditSMSCommandForm
implements Action
{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
private SMSCommandService smsCommandService;
+
+ public void setSmsCommandService( SMSCommandService smsCommandService )
+ {
+ this.smsCommandService = smsCommandService;
+ }
private DataSetService dataSetService;
+
+ public void setDataSetService( DataSetService dataSetService )
+ {
+ this.dataSetService = dataSetService;
+ }
private DataElementService dataElementService;
+
+ public void setDataElementService( DataElementService dataElementService )
+ {
+ this.dataElementService = dataElementService;
+ }
+
+ private UserGroupService userGroupService;
+
+ public void setUserGroupService( UserGroupService userGroupService )
+ {
+ this.userGroupService = userGroupService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input && Output
+ // -------------------------------------------------------------------------
private String name;
private int selectedDataSetID;
+
+ private Integer userGroupID;
private String codeDataelementOption;
@@ -104,6 +136,10 @@
c.setSeparator( separator );
c.setCodes( codeSet );
c.setDefaultMessage( defaultMessage );
+ if( userGroupID != null && userGroupID > -1 )
+ {
+ c.setUserGroup( userGroupService.getUserGroup( userGroupID ) );
+ }
smsCommandService.save( c );
}
@@ -112,7 +148,7 @@
public Collection<DataSet> getDataSets()
{
- return getDataSetService().getAllDataSets();
+ return dataSetService.getAllDataSets();
}
public Set<DataElement> getDataSetElements()
@@ -130,15 +166,6 @@
return smsCommandService.getSMSCommand( selectedCommandID );
}
- public DataSetService getDataSetService()
- {
- return dataSetService;
- }
-
- public void setDataSetService( DataSetService dataSetService )
- {
- this.dataSetService = dataSetService;
- }
public int getSelectedDataSetID()
{
@@ -170,16 +197,6 @@
this.name = name;
}
- public SMSCommandService getSmsCommandService()
- {
- return smsCommandService;
- }
-
- public void setSmsCommandService( SMSCommandService smsCommandService )
- {
- this.smsCommandService = smsCommandService;
- }
-
public int getSelectedCommandID()
{
return selectedCommandID;
@@ -200,16 +217,6 @@
this.separator = separator;
}
- public DataElementService getDataElementService()
- {
- return dataElementService;
- }
-
- public void setDataElementService( DataElementService dataElementService )
- {
- this.dataElementService = dataElementService;
- }
-
public String getCodeSeparator()
{
return codeSeparator;
@@ -247,4 +254,8 @@
}
}
+ public Integer getUserGroupID()
+ {
+ return userGroupID;
+ }
}
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/smscommand/SMSCommandAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/smscommand/SMSCommandAction.java 2013-05-20 09:32:19 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/smscommand/SMSCommandAction.java 2013-05-22 07:06:36 +0000
@@ -81,6 +81,10 @@
// Input & Output
// -------------------------------------------------------------------------
+ private SMSCommand smsCommand;
+
+ private List<DataElement> dataElements;
+
private List<UserGroup> userGroupList;
public List<UserGroup> getUserGroupList()
@@ -125,16 +129,20 @@
public String execute()
throws Exception
{
- if ( getSMSCommand() != null && getSMSCommand().getCodes() != null )
- {
- for ( SMSCode x : getSMSCommand().getCodes() )
+ if ( selectedCommandID > -1 )
+ {
+ smsCommand = smsCommandService.getSMSCommand( selectedCommandID );
+ }
+
+ if ( smsCommand != null && smsCommand.getCodes() != null )
+ {
+ for ( SMSCode x : smsCommand.getCodes() )
{
codes.put( "" + x.getDataElement().getId() + x.getOptionId(), x.getCode() );
}
}
userGroupList = new ArrayList<UserGroup>(userGroupService.getAllUserGroups());
-
return SUCCESS;
}
@@ -142,21 +150,21 @@
// Supporting methods
// -------------------------------------------------------------------------
- public List<DataElement> getDataSetElements()
+ public List<DataElement> getDataElements()
{
- if ( getSMSCommand() != null )
+ if ( smsCommand != null )
{
- DataSet d = getSMSCommand().getDataset();
+ DataSet d = smsCommand.getDataset();
if ( d != null )
{
- List<DataElement> x = new ArrayList<DataElement>( d.getDataElements() );
- Collections.sort( x, new DataElementSortOrderComparator() );
- return x;
+ dataElements = new ArrayList<DataElement>( d.getDataElements() );
+ Collections.sort( dataElements, new DataElementSortOrderComparator() );
+ return dataElements;
}
}
-
return null;
}
+
public Collection<DataSet> getDataSets()
{
@@ -167,16 +175,9 @@
{
return smsCommandService.getSMSCommands();
}
-
- public SMSCommand getSMSCommand()
+
+ public SMSCommand getSmsCommand()
{
- if ( selectedCommandID > -1 )
- {
- return smsCommandService.getSMSCommand( selectedCommandID );
- }
- else
- {
- return null;
- }
- }
+ return smsCommand;
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/META-INF/dhis/beans.xml 2013-05-20 09:32:19 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/META-INF/dhis/beans.xml 2013-05-22 07:06:36 +0000
@@ -154,6 +154,8 @@
ref="org.hisp.dhis.dataset.DataSetService" />
<property name="dataElementService"
ref="org.hisp.dhis.dataelement.DataElementService" />
+ <property name="userGroupService"
+ ref="org.hisp.dhis.user.UserGroupService" />
</bean>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/smscommand/edit-sms-command.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/smscommand/edit-sms-command.vm 2013-03-05 17:06:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/smscommand/edit-sms-command.vm 2013-05-22 07:06:36 +0000
@@ -42,35 +42,53 @@
</tr>
<tr>
<td>$i18n.getString( "name" )</td>
- <td><input type="text" name="name" id="name" value="$SMSCommand.name" style="width:20em" class="validate" /></td>
+ <td><input type="text" name="name" id="name" value="$smsCommand.name" style="width:20em" class="validate" /></td>
+ </tr>
+ <tr>
+ <td>$i18n.getString( "parser" )</td>
+ <td>#if($smsCommand.parserType) $smsCommand.parserType #end</td>
+ </tr>
+
+ #if( $smsCommand.parserType == 'KEY_VALUE_PARSER' || $smsCommand.parserType == 'J2ME_PARSER' )
+ <tr>
+ <td>$i18n.getString( "dataset" )</td>
+ <td>#if($smsCommand.dataset.name) $smsCommand.dataset.name #end</td>
</tr>
<tr>
<td>Use current period for reporting</td>
- <td><input type="checkbox" name="currentPeriodUsedForReporting" #if($SMSCommand.currentPeriodUsedForReporting) checked #end /></td>
- <tr>
- <td>$i18n.getString( "dataset" )</td>
- <td>#if($SMSCommand.dataset.name) $SMSCommand.dataset.name #end</td>
- <tr>
- <tr>
- <td>$i18n.getString( "parser" )</td>
- <td>#if($SMSCommand.parserType) $SMSCommand.parserType #end</td>
+ <td><input type="checkbox" name="currentPeriodUsedForReporting" #if($smsCommand.currentPeriodUsedForReporting) checked #end /></td>
+ </tr>
+
<tr>
<td>$i18n.getString( "code_value_separator" )</td>
<td>
- <input type="text" #if($SMSCommand.separator) value="$SMSCommand.separator" #end name="separator" style="width:20em" class="validate" />
+ <input type="text" #if($smsCommand.separator) value="$smsCommand.separator" #end name="separator" style="width:20em" class="validate" />
</td>
</tr>
- <tr >
+ #elseif( $smsCommand.parserType == 'ALERT_PARSER' )
+ <tr>
+ <td>$i18n.getString( "userGroup" )</td>
+ <td>
+ <select name="userGroupID" >
+ #foreach( $userGroup in $userGroupList )
+ <option value="$userGroup.id" #if($smsCommand.userGroup == $userGroup) selected #end>$userGroup.name</option>
+ #end
+ </select>
+ </td>
+ </tr>
+ #end
+
+ <tr>
<td style="width:150px">$i18n.getString( "no_codes_message" )</td>
- <td><textarea cols="35" type="text" name="defaultMessage">#if($SMSCommand.defaultMessage)$SMSCommand.defaultMessage#end</textarea></td>
+ <td><textarea cols="35" type="text" name="defaultMessage">#if($smsCommand.defaultMessage)$smsCommand.defaultMessage#end</textarea></td>
</tr>
</table>
- </br>
- </br>
-
-
+
+ </br>
+ </br>
+ #if( $smsCommand.parserType == 'KEY_VALUE_PARSER' || $smsCommand.parserType == 'J2ME_PARSER' )
<table id="codes">
<col style="width: 450px"/>
<col/>
@@ -81,7 +99,7 @@
<th>$i18n.getString( "code" )</th>
</tr>
</thead>
- #foreach( $dataElement in $dataSetElements)
+ #foreach( $dataElement in $dataElements)
#if ($dataElement.categoryCombo && $dataElement.categoryCombo.sortedOptionCombos)
#foreach($x in $dataElement.categoryCombo.sortedOptionCombos)
#set ($str = ""+$dataElement.id+""+$x.id)
@@ -102,7 +120,7 @@
#end
#end
</table>
-
+ #end
<br/>
<input type="hidden" name="codeDataelementOption" id="codeDataelementOption" />