use of de.metas.ui.web.handlingunits.HUEditorRow in project metasfresh-webui-api by metasfresh.
the class WebuiHUTransformParametersFiller method getParentHUIdOfSelectedRow.
private int getParentHUIdOfSelectedRow() {
final HUEditorRow huRow = getSelectedRow();
final I_M_HU hu = huRow.getM_HU();
final int parentIdOfSelectedHU = handlingUnitsDAO.retrieveParentId(hu);
return parentIdOfSelectedHU;
}
use of de.metas.ui.web.handlingunits.HUEditorRow 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());
}
use of de.metas.ui.web.handlingunits.HUEditorRow in project metasfresh-webui-api by metasfresh.
the class WebuiHUTransformParametersFiller method getM_HU_PI_Item_IDs.
public LookupValuesList getM_HU_PI_Item_IDs() {
final ActionType actionType = getActionType();
if (actionType != ActionType.TU_To_NewLUs) {
return LookupValuesList.EMPTY;
}
final HUEditorRow tuRow = getSelectedRow();
final I_M_HU tuHU = tuRow.getM_HU();
final I_M_HU_PI_Version effectivePIVersion = handlingUnitsBL.getEffectivePIVersion(tuHU);
Check.errorIf(effectivePIVersion == null, "tuHU is inconsistent; hu={}", tuHU);
final List<I_M_HU_PI_Item> luPIItems = handlingUnitsDAO.retrieveParentPIItemsForParentPI(effectivePIVersion.getM_HU_PI(), null, tuHU.getC_BPartner());
return luPIItems.stream().filter(luPIItem -> luPIItem.getM_HU_PI_Version().isCurrent() && luPIItem.getM_HU_PI_Version().isActive() && luPIItem.getM_HU_PI_Version().getM_HU_PI().isActive()).map(luPIItem -> IntegerLookupValue.of(luPIItem.getM_HU_PI_Item_ID(), WEBUI_ProcessHelper.buildHUPIItemString(luPIItem))).sorted(Comparator.comparing(IntegerLookupValue::getDisplayName)).collect(LookupValuesList.collect());
}
use of de.metas.ui.web.handlingunits.HUEditorRow in project metasfresh-webui-api by metasfresh.
the class WEBUI_M_HU_ReturnTUsToVendor method checkPreconditionsApplicable.
@Override
protected ProcessPreconditionsResolution checkPreconditionsApplicable() {
if (!isHUEditorView()) {
return ProcessPreconditionsResolution.rejectWithInternalReason("not the HU view");
}
final DocumentIdsSelection selectedRowIds = getSelectedRowIds();
if (!selectedRowIds.isSingleDocumentId()) {
return ProcessPreconditionsResolution.rejectBecauseNotSingleSelection();
}
final DocumentId rowId = selectedRowIds.getSingleDocumentId();
final HUEditorRow huRow = getView().getById(rowId);
if (huRow.isLU()) {
if (!huRow.hasIncludedTUs()) {
return ProcessPreconditionsResolution.rejectWithInternalReason("no TUs");
}
} else if (huRow.isTU()) {
// OK
} else {
return ProcessPreconditionsResolution.rejectWithInternalReason("not a LU or TU");
}
return ProcessPreconditionsResolution.accept();
}
use of de.metas.ui.web.handlingunits.HUEditorRow in project metasfresh-webui-api by metasfresh.
the class PickingHUsRepositoryTests method test_retrieveHUsIndexedByPickingSlotId.
private void test_retrieveHUsIndexedByPickingSlotId(@NonNull final String pickingCandidateStatus, final boolean pickingRackSystem) {
final int pickingSlotId = createPickingSlot(pickingRackSystem).getM_PickingSlot_ID();
final I_M_HU hu = newInstance(I_M_HU.class);
hu.setHUStatus(X_M_HU.HUSTATUS_Active);
save(hu);
final int huId = hu.getM_HU_ID();
final I_M_Picking_Candidate pickingCandidate = newInstance(I_M_Picking_Candidate.class);
pickingCandidate.setM_ShipmentSchedule_ID(M_SHIPMENT_SCHEDULE_ID);
pickingCandidate.setM_HU_ID(huId);
pickingCandidate.setM_PickingSlot_ID(pickingSlotId);
pickingCandidate.setStatus(pickingCandidateStatus);
save(pickingCandidate);
final HUEditorRow huEditorRow = HUEditorRow.builder(WindowId.of(423)).setRowId(HUEditorRowId.ofTopLevelHU(huId)).setType(HUEditorRowType.LU).setTopLevel(true).build();
final boolean expectNoRows = X_M_Picking_Candidate.STATUS_CL.equals(pickingCandidateStatus) && pickingRackSystem;
final MockedHUEditorViewRepository huEditorViewRepository = new MockedHUEditorViewRepository();
if (!expectNoRows) {
huEditorViewRepository.addRow(huEditorRow);
}
final PickingHURowsRepository pickingHUsRepository = new PickingHURowsRepository(huEditorViewRepository);
final ListMultimap<Integer, PickedHUEditorRow> result = pickingHUsRepository.retrievePickedHUsIndexedByPickingSlotId(PickingSlotRepoQuery.of(M_SHIPMENT_SCHEDULE_ID));
if (expectNoRows) {
// if 'pickingCandidate' is "closed", then nothing shall be returned
assertThat(result.isEmpty()).isTrue();
} else {
assertThat(result.size()).isEqualTo(1);
assertThat(result.get(pickingSlotId)).hasSize(1);
final boolean expectedProcessed = !X_M_Picking_Candidate.STATUS_IP.equals(pickingCandidateStatus);
final PickedHUEditorRow resultRow = result.get(pickingSlotId).get(0);
final PickedHUEditorRow expectedRow = new PickedHUEditorRow(huEditorRow, expectedProcessed);
assertThat(resultRow).isEqualTo(expectedRow);
}
}
Aggregations