Moved method to get currency symbol to Util class

FEA: ItEr76S25CurrencyManagement
This commit is contained in:
Manuel Rego Casasnovas 2012-04-27 08:08:33 +02:00
parent cb8feeea58
commit 77d2fd65fa
5 changed files with 24 additions and 17 deletions

View file

@ -31,6 +31,9 @@ import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.libreplan.business.common.Configuration;
import org.libreplan.business.common.IOnTransaction;
import org.libreplan.business.common.Registry;
import org.zkoss.ganttz.util.ComponentsFinder;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.Event;
@ -629,4 +632,20 @@ public class Util {
}
}
/**
* Gets currency symbol from {@link Configuration} object.
*
* @return Currency symbol configured in the application
*/
public static String getCurrencySymbol() {
return Registry.getTransactionService().runOnReadOnlyTransaction(
new IOnTransaction<String>() {
@Override
public String execute() {
return Registry.getConfigurationDAO()
.getConfiguration().getCurrencySymbol();
}
});
}
}

View file

@ -89,6 +89,7 @@ import org.libreplan.business.workingday.EffortDuration;
import org.libreplan.business.workingday.EffortDuration.IEffortFrom;
import org.libreplan.business.workingday.IntraDayDate;
import org.libreplan.business.workingday.IntraDayDate.PartialDay;
import org.libreplan.web.common.Util;
import org.libreplan.web.planner.order.PlanningStateCreator.PlanningState;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanDefinition;
@ -1033,14 +1034,9 @@ public class TaskElementAdapter {
if (taskElement.getOrderElement() instanceof Order) {
result.append(_("State") + ": ").append(getOrderState());
} else {
String budget = getBudget()
+ " "
+ configurationDAO.getConfiguration()
.getCurrencySymbol();
String moneyCost = getMoneyCost()
+ " "
+ configurationDAO.getConfiguration()
.getCurrencySymbol();
String currencySymbol = Util.getCurrencySymbol();
String budget = getBudget() + " " + currencySymbol;
String moneyCost = getMoneyCost() + " " + currencySymbol;
result.append(
_("Budget: {0}, Consumed: {1} ({2}%)", budget,
moneyCost, getMoneyCostBarPercentage()

View file

@ -69,5 +69,4 @@ public interface IOrderCostsPerResourceModel {
String getSelectedLabel();
String getCurrencySymbol();
}

View file

@ -88,8 +88,7 @@ public class OrderCostsPerResourceController extends LibrePlanReportController {
result.put("endingDate", getEndingDate());
result.put("criteria", getParameterCriterions());
result.put("labels", getParameterLabels());
result.put("currencySymbol",
orderCostsPerResourceModel.getCurrencySymbol());
result.put("currencySymbol", Util.getCurrencySymbol());
return result;
}

View file

@ -415,10 +415,4 @@ public class OrderCostsPerResourceModel implements IOrderCostsPerResourceModel {
return selectedCriteria;
}
@Override
@Transactional(readOnly = true)
public String getCurrencySymbol() {
return configurationDAO.getConfiguration().getCurrencySymbol();
}
}