Use code to go to entry points when possible

Modify entry points converters for entities extending IntegrationEntity in order
to use code instead of id. In that way user can see the code in the UI without
having to query the database.

FEA: ItEr77S04BugFixing
This commit is contained in:
Manuel Rego Casasnovas 2012-10-19 14:37:20 +02:00
parent 07ca5fd443
commit fd74722614
8 changed files with 15 additions and 14 deletions

View file

@ -60,6 +60,7 @@ public class IntegrationEntityDAO<E extends IntegrationEntity>
@SuppressWarnings("unchecked")
@Override
@Transactional(readOnly = true)
public E findByCode(String code) throws InstanceNotFoundException {
if (StringUtils.isBlank(code)) {

View file

@ -202,6 +202,7 @@ public class OrderElementDAO extends IntegrationEntityDAO<OrderElement>
@SuppressWarnings("unchecked")
@Override
@Transactional(readOnly = true)
public OrderElement findByCode(String code)
throws InstanceNotFoundException {

View file

@ -45,13 +45,13 @@ public class ExpenseSheetConverter implements IConverter<ExpenseSheet> {
@Override
public String asString(ExpenseSheet entity) {
return entity.getId().toString();
return entity.getCode();
}
@Override
public ExpenseSheet asObject(String stringRepresentation) {
try {
return expenseSheetDAO.find(Long.parseLong(stringRepresentation));
return expenseSheetDAO.findByCode(stringRepresentation);
} catch (InstanceNotFoundException e) {
throw new RuntimeException(e);
}

View file

@ -45,7 +45,7 @@ public class OrderConverter implements IConverter<Order> {
@Transactional(readOnly = true)
public Order asObject(String stringRepresentation) {
try {
return orderDAO.find(Long.parseLong(stringRepresentation));
return orderDAO.findByCode(stringRepresentation);
} catch (InstanceNotFoundException e) {
throw new RuntimeException(e);
}
@ -53,7 +53,7 @@ public class OrderConverter implements IConverter<Order> {
@Override
public String asString(Order entity) {
return entity.getId() + "";
return entity.getCode();
}
@Override

View file

@ -42,7 +42,7 @@ public class OrderElementConverter implements IConverter<OrderElement> {
@Override
public OrderElement asObject(String stringRepresentation) {
try {
return orderElementDAO.find(Long.parseLong(stringRepresentation));
return orderElementDAO.findByCode(stringRepresentation);
} catch (InstanceNotFoundException e) {
throw new RuntimeException(e);
}
@ -50,7 +50,7 @@ public class OrderElementConverter implements IConverter<OrderElement> {
@Override
public String asString(OrderElement entity) {
return entity.getId() + "";
return entity.getCode();
}
@Override

View file

@ -44,9 +44,8 @@ public class ResourceConverter implements IConverter<Resource> {
@Override
@Transactional(readOnly = true)
public Resource asObject(String stringRepresentation) {
long id = Long.parseLong(stringRepresentation);
try {
return resourceDAO.find(id);
return resourceDAO.findByCode(stringRepresentation);
} catch (InstanceNotFoundException e) {
throw new RuntimeException(e);
}
@ -54,7 +53,7 @@ public class ResourceConverter implements IConverter<Resource> {
@Override
public String asString(Resource entity) {
return entity.getId() + "";
return entity.getCode();
}
@Override

View file

@ -46,13 +46,13 @@ public class WorkReportConverter implements IConverter<WorkReport> {
@Override
public String asString(WorkReport entity) {
return entity.getId() + "";
return entity.getCode();
}
@Override
public WorkReport asObject(String stringRepresentation) {
try {
return workReportDAO.find(Long.parseLong(stringRepresentation));
return workReportDAO.findByCode(stringRepresentation);
} catch (InstanceNotFoundException e) {
throw new RuntimeException(e);
}

View file

@ -40,9 +40,9 @@ public class WorkReportTypeConverter implements IConverter<WorkReportType> {
@Override
@Transactional(readOnly = true)
public WorkReportType asObject(String stringRepresentation) {
long id = Long.parseLong(stringRepresentation);
try {
WorkReportType workReportType = workReportTypeDAO.find(id);
WorkReportType workReportType = workReportTypeDAO
.findByCode(stringRepresentation);
return workReportType;
} catch (InstanceNotFoundException e) {
throw new RuntimeException(e);
@ -51,7 +51,7 @@ public class WorkReportTypeConverter implements IConverter<WorkReportType> {
@Override
public String asString(WorkReportType entity) {
return entity.getId().toString();
return entity.getCode();
}
@Override