use of org.adempiere.ad.service.IADReferenceDAO.ADRefListItem in project metasfresh-webui-api by metasfresh.
the class WebuiHUTransformParametersFiller method getActions.
/**
* @return the actions that are available according to which row is currently selected and to also according to whether there are already existing TUs or LUs in the context.
*/
public final LookupValuesList getActions(final int processId) {
final Set<String> allowedActions = new HashSet<>();
final HUEditorRow huRow = getSelectedRow();
if (huRow.isCU()) {
allowedActions.addAll(getActionTypesForCUs());
} else if (huRow.isTU()) {
allowedActions.addAll(getActionTypesForTUs());
} else if (huRow.isLU()) {
allowedActions.add(ActionType.LU_Set_Ownership.toString());
}
final IADProcessDAO adProcessDAO = Services.get(IADProcessDAO.class);
final I_AD_Process_Para processParameter = adProcessDAO.retriveProcessParameter(Env.getCtx(), processId, WEBUI_M_HU_Transform.PARAM_Action);
final int actionsReferenceId = processParameter.getAD_Reference_Value_ID();
final Collection<ADRefListItem> allActiveActionItems = adReferenceDAO.retrieveListItems(actionsReferenceId);
final String adLanguage = Env.getAD_Language();
return allActiveActionItems.stream().filter(item -> allowedActions.contains(item.getValueName())).map(item -> StringLookupValue.of(item.getValueName(), item.getName())).sorted(Comparator.comparing(lookupValue -> lookupValue.getDisplayName(adLanguage))).collect(LookupValuesList.collect());
}
Aggregations