use of de.metas.ui.web.window.datatypes.WindowId in project metasfresh-webui-api by metasfresh.
the class ViewIdTests method test_ofViewIdString_CorrectWindowId.
@Test
public void test_ofViewIdString_CorrectWindowId() {
final ViewId viewId = randomViewId();
final WindowId expectedWindowId = viewId.getWindowId();
final ViewId viewId2 = ViewId.ofViewIdString(viewId.getViewId(), expectedWindowId);
Assert.assertEquals(viewId, viewId2);
}
use of de.metas.ui.web.window.datatypes.WindowId in project metasfresh-webui-api by metasfresh.
the class ViewIdTests method test_ofViewIdString_WrongWindowId.
@Test
public void test_ofViewIdString_WrongWindowId() {
final ViewId viewId = randomViewId();
final WindowId expectedWindowId = randomWindowIdButNot(viewId.getWindowId());
try {
final ViewId viewId2 = ViewId.ofViewIdString(viewId.getViewId(), expectedWindowId);
Assert.fail("Exception was expected because windowId are not matching: viewId2=" + viewId2 + ", expectedWindowId=" + expectedWindowId);
} catch (final IllegalArgumentException ex) {
// OK
}
}
use of de.metas.ui.web.window.datatypes.WindowId in project metasfresh-webui-api by metasfresh.
the class HUEditorViewFactoryTemplate method extractReferencingTablename.
private String extractReferencingTablename(final Set<DocumentPath> referencingDocumentPaths) {
final String referencingTableName;
if (!referencingDocumentPaths.isEmpty()) {
// assuming all document paths have the same window
final WindowId referencingWindowId = referencingDocumentPaths.iterator().next().getWindowId();
referencingTableName = documentDescriptorFactory.getDocumentEntityDescriptor(referencingWindowId).getTableNameOrNull();
} else {
referencingTableName = null;
}
return referencingTableName;
}
use of de.metas.ui.web.window.datatypes.WindowId in project metasfresh-webui-api by metasfresh.
the class SqlHUEditorViewRepository method createHUEditorRow.
private HUEditorRow createHUEditorRow(@NonNull final I_M_HU hu, final int topLevelHUId) {
// final Stopwatch stopwatch = Stopwatch.createStarted();
final IHandlingUnitsBL handlingUnitsBL = Services.get(IHandlingUnitsBL.class);
final boolean aggregatedTU = handlingUnitsBL.isAggregateHU(hu);
final String huUnitTypeCode = handlingUnitsBL.getHU_UnitType(hu);
final HUEditorRowType huRecordType;
if (aggregatedTU) {
huRecordType = HUEditorRowType.TU;
} else {
huRecordType = HUEditorRowType.ofHU_UnitType(huUnitTypeCode);
}
final String huUnitTypeDisplayName = huRecordType.getName();
final JSONLookupValue huUnitTypeLookupValue = JSONLookupValue.of(huUnitTypeCode, huUnitTypeDisplayName);
final JSONLookupValue huStatus = createHUStatusLookupValue(hu);
final boolean processed = rowProcessedPredicate.isProcessed(hu);
final int huId = hu.getM_HU_ID();
final HUEditorRowId rowId = HUEditorRowId.ofHU(huId, topLevelHUId);
final HUEditorRow.Builder huEditorRow = HUEditorRow.builder(windowId).setRowId(rowId).setType(huRecordType).setTopLevel(topLevelHUId <= 0).setProcessed(processed).setBPartnerId(hu.getC_BPartner_ID()).setAttributesProvider(attributesProvider).setCode(hu.getValue()).setHUUnitType(huUnitTypeLookupValue).setHUStatus(huStatus).setPackingInfo(extractPackingInfo(hu, huRecordType));
// Acquire Best Before Date if required
if (showBestBeforeDate) {
huEditorRow.setBestBeforeDate(extractBestBeforeDate(attributesProvider, rowId));
}
// Locator
if (showLocator) {
huEditorRow.setLocator(createLocatorLookupValue(hu.getM_Locator_ID()));
}
//
// Product/UOM/Qty if there is only one product stored
final IHUProductStorage singleProductStorage = getSingleProductStorage(hu);
if (singleProductStorage != null) {
huEditorRow.setProduct(createProductLookupValue(singleProductStorage.getM_Product())).setUOM(createUOMLookupValue(singleProductStorage.getC_UOM())).setQtyCU(singleProductStorage.getQty());
}
//
// Included HUs
final int topLevelHUIdEffective = topLevelHUId > 0 ? topLevelHUId : huId;
if (aggregatedTU) {
final IHUStorageFactory storageFactory = handlingUnitsBL.getStorageFactory();
storageFactory.getStorage(hu).getProductStorages().stream().map(huStorage -> createHUEditorRow(huId, topLevelHUIdEffective, huStorage, processed)).forEach(huEditorRow::addIncludedRow);
} else if (X_M_HU_PI_Version.HU_UNITTYPE_LoadLogistiqueUnit.equals(huUnitTypeCode)) {
final IHandlingUnitsDAO handlingUnitsDAO = Services.get(IHandlingUnitsDAO.class);
handlingUnitsDAO.retrieveIncludedHUs(hu).stream().map(includedHU -> createHUEditorRow(includedHU, topLevelHUIdEffective)).forEach(huEditorRow::addIncludedRow);
} else if (X_M_HU_PI_Version.HU_UNITTYPE_TransportUnit.equals(huUnitTypeCode)) {
final IHandlingUnitsDAO handlingUnitsDAO = Services.get(IHandlingUnitsDAO.class);
final IHUStorageFactory storageFactory = handlingUnitsBL.getStorageFactory();
handlingUnitsDAO.retrieveIncludedHUs(hu).stream().map(includedVHU -> storageFactory.getStorage(includedVHU)).flatMap(vhuStorage -> vhuStorage.getProductStorages().stream()).map(vhuProductStorage -> createHUEditorRow(huId, topLevelHUIdEffective, vhuProductStorage, processed)).forEach(huEditorRow::addIncludedRow);
} else if (X_M_HU_PI_Version.HU_UNITTYPE_VirtualPI.equals(huUnitTypeCode)) {
// do nothing
} else {
throw new HUException("Unknown HU_UnitType=" + huUnitTypeCode + " for " + hu);
}
final HUEditorRow huEditorRowBuilt = huEditorRow.build();
return huEditorRowBuilt;
}
use of de.metas.ui.web.window.datatypes.WindowId in project metasfresh-webui-api by metasfresh.
the class MaterialCockpitViewFactory method assertWindowIdOfRequestIsCorrect.
private void assertWindowIdOfRequestIsCorrect(@NonNull final CreateViewRequest request) {
final ViewId viewId = request.getViewId();
final WindowId windowId = viewId.getWindowId();
Check.errorUnless(MaterialCockpitConstants.WINDOWID_MaterialCockpitView.equals(windowId), "The parameter request needs to have WindowId={}, but has {} instead; request={};", MaterialCockpitConstants.WINDOWID_MaterialCockpitView, windowId, request);
}
Aggregations