[Bug #1117] Fix issue changing I18nHelper in business.
Current I18nHelper in business was doing real translation of strings. Then it was passing the string translated to server language to webapp module and this module tries to translate the string again to end-user language. In order to avoid this I18nHelper in business is modified and now it just provides a marker method for translatable strings. Real translation is going to be done in webapp module. Several files need to be modified due to this change. FEA: ItEr75S04BugFixing
This commit is contained in:
parent
ed79e453f6
commit
e8d904abbe
19 changed files with 94 additions and 116 deletions
|
|
@ -136,9 +136,9 @@ public class EntitySequence extends BaseEntity {
|
|||
&& (numberOfDigits <= MAX_NUMBER_OF_DIGITS)) {
|
||||
this.numberOfDigits = numberOfDigits;
|
||||
} else {
|
||||
throw new IllegalArgumentException(I18nHelper._(
|
||||
"number of digits must be between {0} and {1}",
|
||||
MIN_NUMBER_OF_DIGITS, MAX_NUMBER_OF_DIGITS));
|
||||
throw new IllegalArgumentException(
|
||||
"number of digits must be between " + MIN_NUMBER_OF_DIGITS
|
||||
+ " and " + MAX_NUMBER_OF_DIGITS);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,44 +21,22 @@
|
|||
|
||||
package org.navalplanner.business.i18n;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.xnap.commons.i18n.I18n;
|
||||
import org.xnap.commons.i18n.I18nFactory;
|
||||
|
||||
/**
|
||||
* This class provides a function to mark strings to be translated. Real
|
||||
* translation have to be done in webapp module depending on user language and
|
||||
* not done here depending on server language.
|
||||
*
|
||||
* @author Manuel Rego Casasnovas <rego@igalia.com>
|
||||
*/
|
||||
public class I18nHelper {
|
||||
|
||||
private I18nHelper() {
|
||||
|
||||
}
|
||||
|
||||
public static I18n getI18n() {
|
||||
return I18nFactory.getI18n(I18nHelper.class, Locale.getDefault(),
|
||||
org.xnap.commons.i18n.I18nFactory.FALLBACK);
|
||||
}
|
||||
|
||||
public static String _(String text) {
|
||||
return getI18n().tr(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
public static String _(String text, Object o1) {
|
||||
return getI18n().tr(text, o1);
|
||||
}
|
||||
|
||||
public static String _(String text, Object o1, Object o2) {
|
||||
return getI18n().tr(text, o1, o2);
|
||||
}
|
||||
|
||||
public static String _(String text, Object o1, Object o2, Object o3) {
|
||||
return getI18n().tr(text, o1, o2, o3);
|
||||
}
|
||||
|
||||
public static String _(String text, Object o1, Object o2, Object o3,
|
||||
Object o4) {
|
||||
return getI18n().tr(text, o1, o2, o3, o4);
|
||||
}
|
||||
|
||||
public static String _(String text, Object[] objects) {
|
||||
return getI18n().tr(text, objects);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -535,10 +535,8 @@ public abstract class CriterionRequirementHandler<T, S, R> {
|
|||
propagateDirectCriterionRequirementAddition(orderElement,
|
||||
newRequirement);
|
||||
} else {
|
||||
final Criterion criterion = newRequirement.getCriterion();
|
||||
throw new IllegalStateException(_(
|
||||
" The {0} already exist into other task",
|
||||
criterion.getName()));
|
||||
throw new IllegalStateException(
|
||||
_("The criterion already exist into other task"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ import org.hibernate.validator.Valid;
|
|||
import org.navalplanner.business.common.IntegrationEntity;
|
||||
import org.navalplanner.business.common.Registry;
|
||||
import org.navalplanner.business.common.daos.IIntegrationEntityDAO;
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
import org.navalplanner.business.requirements.entities.CriterionRequirement;
|
||||
import org.navalplanner.business.requirements.entities.DirectCriterionRequirement;
|
||||
import org.navalplanner.business.requirements.entities.IndirectCriterionRequirement;
|
||||
|
|
@ -255,15 +254,11 @@ public class HoursGroup extends IntegrationEntity implements Cloneable,
|
|||
public void addCriterionRequirement(CriterionRequirement requirement) {
|
||||
if (!isValidResourceType(requirement)) {
|
||||
throw new IllegalStateException(
|
||||
_(
|
||||
" The criterion {0} can not be assigned to this hoursGroup because its resource type is diferent.",
|
||||
requirement.getCriterion().getName()));
|
||||
_("The criterion can not be assigned to this hoursGroup because its resource type is diferent"));
|
||||
}
|
||||
if (existSameCriterionRequirement(requirement)) {
|
||||
throw new IllegalStateException(
|
||||
_(
|
||||
" The criterion {0} can not be assigned to this hoursGroup because it already exist into the hoursGroup.",
|
||||
requirement.getCriterion().getName()));
|
||||
_("The criterion can not be assigned to this hoursGroup because it already exist into the hoursGroup"));
|
||||
|
||||
}
|
||||
requirement.setHoursGroup(this);
|
||||
|
|
@ -411,27 +406,4 @@ public class HoursGroup extends IntegrationEntity implements Cloneable,
|
|||
return true;
|
||||
}
|
||||
|
||||
public static void checkConstraintHoursGroupUniqueCode(OrderElement order) {
|
||||
HoursGroup repeatedHoursGroup;
|
||||
|
||||
if (order instanceof OrderLineGroup) {
|
||||
repeatedHoursGroup = ((OrderLineGroup) order).findRepeatedHoursGroupCode();
|
||||
if (repeatedHoursGroup != null) {
|
||||
throw new ValidationException(_(
|
||||
"Repeated Hours Group code {0} in Project {1}",
|
||||
repeatedHoursGroup.getCode(), repeatedHoursGroup
|
||||
.getParentOrderLine().getName()));
|
||||
}
|
||||
}
|
||||
|
||||
repeatedHoursGroup = Registry.getHoursGroupDAO()
|
||||
.findRepeatedHoursGroupCodeInDB(order.getHoursGroups());
|
||||
if (repeatedHoursGroup != null) {
|
||||
throw new ValidationException(_(
|
||||
"Repeated Hours Group code {0} in Project {1}",
|
||||
repeatedHoursGroup.getCode(), repeatedHoursGroup
|
||||
.getParentOrderLine().getName()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1049,10 +1049,9 @@ public abstract class OrderElement extends IntegrationEntity implements
|
|||
Validate.notNull(qualityForm);
|
||||
for (TaskQualityForm taskQualityForm : getTaskQualityForms()) {
|
||||
if (qualityForm.equals(taskQualityForm.getQualityForm())) {
|
||||
throw new ValidationException(new InvalidValue(_(
|
||||
"{0} already exists", qualityForm.getName()),
|
||||
QualityForm.class, "name", qualityForm.getName(),
|
||||
qualityForm));
|
||||
throw new ValidationException(new InvalidValue(
|
||||
_("Quality form already exists"), QualityForm.class,
|
||||
"name", qualityForm.getName(), qualityForm));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1338,29 +1337,6 @@ public abstract class OrderElement extends IntegrationEntity implements
|
|||
}
|
||||
}
|
||||
|
||||
public static void checkConstraintOrderUniqueCode(OrderElement order) {
|
||||
OrderElement repeatedOrder;
|
||||
|
||||
// Check no code is repeated in this order
|
||||
if (order instanceof OrderLineGroup) {
|
||||
repeatedOrder = ((OrderLineGroup) order).findRepeatedOrderCode();
|
||||
if (repeatedOrder != null) {
|
||||
throw new ValidationException(_(
|
||||
"Repeated Project code {0} in Project {1}",
|
||||
repeatedOrder.getCode(), repeatedOrder.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
// Check no code is repeated within the DB
|
||||
repeatedOrder = Registry.getOrderElementDAO()
|
||||
.findRepeatedOrderCodeInDB(order);
|
||||
if (repeatedOrder != null) {
|
||||
throw new ValidationException(_(
|
||||
"Repeated Project code {0} in Project {1}",
|
||||
repeatedOrder.getCode(), repeatedOrder.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
public void setCodeAutogenerated(Boolean codeAutogenerated) {
|
||||
if (getOrder().equals(this)) {
|
||||
super.setCodeAutogenerated(codeAutogenerated);
|
||||
|
|
|
|||
|
|
@ -165,9 +165,9 @@ public class SchedulingState {
|
|||
this(type);
|
||||
for (SchedulingState each : children) {
|
||||
if (!each.isRoot()) {
|
||||
throw new IllegalArgumentException(_(
|
||||
"{0} is already child of another {1}", each,
|
||||
SchedulingState.class.getSimpleName()));
|
||||
throw new IllegalArgumentException(each
|
||||
+ " is already child of another "
|
||||
+ SchedulingState.class.getSimpleName());
|
||||
}
|
||||
add(each);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,8 +21,6 @@
|
|||
|
||||
package org.navalplanner.business.scenarios.entities;
|
||||
|
||||
import static org.navalplanner.business.i18n.I18nHelper._;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
|
@ -174,7 +172,7 @@ public class Scenario extends BaseEntity implements IHumanIdentifiable {
|
|||
}
|
||||
|
||||
public Scenario newDerivedScenario() {
|
||||
Scenario result = new Scenario(_("Derived from {0}", name), this);
|
||||
Scenario result = new Scenario("Derived from " + name, this);
|
||||
for (Order order : orders.keySet()) {
|
||||
result.addOrder(order, orders.get(order));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -293,7 +293,10 @@ public class ConfigurationController extends GenericForwardComposer {
|
|||
seq.setNumberOfDigits(digitsBox.getValue());
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new WrongValueException(digitsBox, e.getMessage());
|
||||
throw new WrongValueException(digitsBox, _(
|
||||
"number of digits must be between {0} and {1}",
|
||||
EntitySequence.MIN_NUMBER_OF_DIGITS,
|
||||
EntitySequence.MAX_NUMBER_OF_DIGITS));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -599,8 +602,10 @@ public class ConfigurationController extends GenericForwardComposer {
|
|||
try {
|
||||
entitySequence.setNumberOfDigits(value);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new WrongValueException(tempIntbox, e
|
||||
.getMessage());
|
||||
throw new WrongValueException(tempIntbox, _(
|
||||
"number of digits must be between {0} and {1}",
|
||||
EntitySequence.MIN_NUMBER_OF_DIGITS,
|
||||
EntitySequence.MAX_NUMBER_OF_DIGITS));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -696,7 +701,10 @@ public class ConfigurationController extends GenericForwardComposer {
|
|||
try {
|
||||
sequence.setNumberOfDigits(numberOfDigits);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new WrongValueException(comp, e.getMessage());
|
||||
throw new WrongValueException(comp, _(
|
||||
"number of digits must be between {0} and {1}",
|
||||
EntitySequence.MIN_NUMBER_OF_DIGITS,
|
||||
EntitySequence.MAX_NUMBER_OF_DIGITS));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
package org.navalplanner.web.common;
|
||||
|
||||
import static org.navalplanner.business.i18n.I18nHelper._;
|
||||
import static org.navalplanner.web.I18nHelper._;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
package org.navalplanner.web.exceptionDays;
|
||||
|
||||
import static org.navalplanner.business.i18n.I18nHelper._;
|
||||
import static org.navalplanner.web.I18nHelper._;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
package org.navalplanner.web.orders;
|
||||
|
||||
import static org.navalplanner.business.i18n.I18nHelper._;
|
||||
import static org.navalplanner.web.I18nHelper._;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ import org.navalplanner.business.common.BaseEntity;
|
|||
import org.navalplanner.business.common.IAdHocTransactionService;
|
||||
import org.navalplanner.business.common.IOnTransaction;
|
||||
import org.navalplanner.business.common.IntegrationEntity;
|
||||
import org.navalplanner.business.common.Registry;
|
||||
import org.navalplanner.business.common.daos.IConfigurationDAO;
|
||||
import org.navalplanner.business.common.entities.Configuration;
|
||||
import org.navalplanner.business.common.entities.EntityNameEnum;
|
||||
|
|
@ -544,8 +545,8 @@ public class OrderModel extends IntegrationEntityModel implements IOrderModel {
|
|||
}
|
||||
|
||||
private void saveOnTransaction(boolean newOrderVersionNeeded) {
|
||||
Order.checkConstraintOrderUniqueCode(order);
|
||||
HoursGroup.checkConstraintHoursGroupUniqueCode(order);
|
||||
checkConstraintOrderUniqueCode(order);
|
||||
checkConstraintHoursGroupUniqueCode(order);
|
||||
|
||||
reattachCalendar();
|
||||
reattachCriterions();
|
||||
|
|
@ -577,6 +578,53 @@ public class OrderModel extends IntegrationEntityModel implements IOrderModel {
|
|||
deleteOrderElementWithoutParent();
|
||||
}
|
||||
|
||||
private static void checkConstraintOrderUniqueCode(OrderElement order) {
|
||||
OrderElement repeatedOrder;
|
||||
|
||||
// Check no code is repeated in this order
|
||||
if (order instanceof OrderLineGroup) {
|
||||
repeatedOrder = ((OrderLineGroup) order).findRepeatedOrderCode();
|
||||
if (repeatedOrder != null) {
|
||||
throw new ValidationException(_(
|
||||
"Repeated Project code {0} in Project {1}",
|
||||
repeatedOrder.getCode(), repeatedOrder.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
// Check no code is repeated within the DB
|
||||
repeatedOrder = Registry.getOrderElementDAO()
|
||||
.findRepeatedOrderCodeInDB(order);
|
||||
if (repeatedOrder != null) {
|
||||
throw new ValidationException(_(
|
||||
"Repeated Project code {0} in Project {1}",
|
||||
repeatedOrder.getCode(), repeatedOrder.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkConstraintHoursGroupUniqueCode(Order order) {
|
||||
HoursGroup repeatedHoursGroup;
|
||||
|
||||
if (order instanceof OrderLineGroup) {
|
||||
repeatedHoursGroup = ((OrderLineGroup) order)
|
||||
.findRepeatedHoursGroupCode();
|
||||
if (repeatedHoursGroup != null) {
|
||||
throw new ValidationException(_(
|
||||
"Repeated Hours Group code {0} in Project {1}",
|
||||
repeatedHoursGroup.getCode(), repeatedHoursGroup
|
||||
.getParentOrderLine().getName()));
|
||||
}
|
||||
}
|
||||
|
||||
repeatedHoursGroup = Registry.getHoursGroupDAO()
|
||||
.findRepeatedHoursGroupCodeInDB(order.getHoursGroups());
|
||||
if (repeatedHoursGroup != null) {
|
||||
throw new ValidationException(_(
|
||||
"Repeated Hours Group code {0} in Project {1}",
|
||||
repeatedHoursGroup.getCode(), repeatedHoursGroup
|
||||
.getParentOrderLine().getName()));
|
||||
}
|
||||
}
|
||||
|
||||
private void createAndSaveNewOrderVersion(Scenario currentScenario,
|
||||
OrderVersion newOrderVersion) {
|
||||
OrderVersion previousOrderVersion = currentScenario
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
*/
|
||||
package org.navalplanner.web.orders.assigntemplates;
|
||||
|
||||
import static org.navalplanner.business.i18n.I18nHelper._;
|
||||
import static org.navalplanner.web.I18nHelper._;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.navalplanner.business.templates.entities.OrderElementTemplate;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
*/
|
||||
package org.navalplanner.web.planner.reassign;
|
||||
|
||||
import static org.navalplanner.business.i18n.I18nHelper._;
|
||||
import static org.navalplanner.web.I18nHelper._;
|
||||
import static org.zkoss.ganttz.util.LongOperationFeedback.and;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
*/
|
||||
package org.navalplanner.web.planner.reassign;
|
||||
|
||||
import static org.navalplanner.business.i18n.I18nHelper._;
|
||||
import static org.navalplanner.web.I18nHelper._;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
package org.navalplanner.web.templates;
|
||||
|
||||
import static org.navalplanner.business.i18n.I18nHelper._;
|
||||
import static org.navalplanner.web.I18nHelper._;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
*/
|
||||
package org.navalplanner.web.templates;
|
||||
|
||||
import static org.navalplanner.business.i18n.I18nHelper._;
|
||||
import static org.navalplanner.web.I18nHelper._;
|
||||
|
||||
import org.navalplanner.business.templates.entities.OrderElementTemplate;
|
||||
import org.navalplanner.business.templates.entities.OrderLineTemplate;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
package org.navalplanner.web.workreports;
|
||||
|
||||
import static org.navalplanner.business.i18n.I18nHelper._;
|
||||
import static org.navalplanner.web.I18nHelper._;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
|
|
|||
|
|
@ -316,7 +316,7 @@ public final class OrderElementConverter {
|
|||
.addCriterionRequirement(DirectCriterionRequirement
|
||||
.create(criterion));
|
||||
} catch (IllegalStateException e) {
|
||||
throw new ValidationException(e.getMessage());
|
||||
throw new ValidationException(_(e.getMessage()));
|
||||
}
|
||||
}
|
||||
} else { // criterionRequirementDTO instanceof
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue