@In
private TransUnitUtils transUnitUtils;
@Override
public Response get(String localeId, String ids) {
TransUnits transUnits = new TransUnits();
if (StringUtils.isEmpty(ids)) {
return Response.ok(transUnits).build();
}
List<Long> idList = TransUnitUtils.filterAndConvertIdsToList(ids);
if (idList.size() > TransUnitUtils.MAX_SIZE) {
return Response.status(Response.Status.FORBIDDEN).build();
}
HLocale locale = localeServiceImpl.getByLocaleId(localeId);
List<Object[]> results =
textFlowDAO.getTextFlowAndTarget(idList, locale.getId());
for (Object[] result : results) {
HTextFlow textFlow = (HTextFlow) result[0];
TransUnit tu;
if (result.length < 2 || result[1] == null) {
tu = transUnitUtils.buildTransUnitFull(textFlow, null,
locale.getLocaleId());
}
else {
HTextFlowTarget textFlowTarget = (HTextFlowTarget) result[1];
tu = transUnitUtils.buildTransUnitFull(textFlow,
textFlowTarget, locale.getLocaleId());
}
transUnits.put(textFlow.getId().toString(), tu);
}
return Response.ok(transUnits).build();
}