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:
parent
07ca5fd443
commit
fd74722614
8 changed files with 15 additions and 14 deletions
|
|
@ -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)) {
|
||||
|
|
|
|||
|
|
@ -202,6 +202,7 @@ public class OrderElementDAO extends IntegrationEntityDAO<OrderElement>
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public OrderElement findByCode(String code)
|
||||
throws InstanceNotFoundException {
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue