Search in sources :

Example 26 with WindowId

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);
}
Also used : WindowId(de.metas.ui.web.window.datatypes.WindowId) Test(org.junit.Test)

Example 27 with WindowId

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
    }
}
Also used : WindowId(de.metas.ui.web.window.datatypes.WindowId) Test(org.junit.Test)

Example 28 with WindowId

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;
}
Also used : WindowId(de.metas.ui.web.window.datatypes.WindowId) ITranslatableString(de.metas.i18n.ITranslatableString)

Example 29 with WindowId

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;
}
Also used : IHUStorageFactory(de.metas.handlingunits.storage.IHUStorageFactory) SqlViewRowIdsConverter(de.metas.ui.web.view.descriptor.SqlViewRowIdsConverter) Date(java.util.Date) ViewEvaluationCtx(de.metas.ui.web.view.ViewEvaluationCtx) ITrx(org.adempiere.ad.trx.api.ITrx) SqlDocumentFilterConverters(de.metas.ui.web.document.filter.sql.SqlDocumentFilterConverters) ResultSet(java.sql.ResultSet) IHUQueryBuilder(de.metas.handlingunits.IHUQueryBuilder) IADReferenceDAO(org.adempiere.ad.service.IADReferenceDAO) HUPackingInfos(de.metas.ui.web.handlingunits.util.HUPackingInfos) ImmutableSet(com.google.common.collect.ImmutableSet) NonNull(lombok.NonNull) Collection(java.util.Collection) Set(java.util.Set) IQueryBuilder(org.adempiere.ad.dao.IQueryBuilder) SqlViewBinding(de.metas.ui.web.view.descriptor.SqlViewBinding) PreparedStatement(java.sql.PreparedStatement) Collectors(java.util.stream.Collectors) I_M_Locator(de.metas.handlingunits.model.I_M_Locator) DBException(org.adempiere.exceptions.DBException) Services(org.adempiere.util.Services) List(java.util.List) SqlViewRowIdsOrderedSelectionFactory(de.metas.ui.web.view.SqlViewRowIdsOrderedSelectionFactory) Stream(java.util.stream.Stream) Builder(lombok.Builder) I_M_Warehouse(de.metas.handlingunits.model.I_M_Warehouse) LogManager(de.metas.logging.LogManager) IHandlingUnitsBL(de.metas.handlingunits.IHandlingUnitsBL) HUException(de.metas.handlingunits.exceptions.HUException) ViewRowIdsOrderedSelection(de.metas.ui.web.view.ViewRowIdsOrderedSelection) GuavaCollectors(org.adempiere.util.GuavaCollectors) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) InterfaceWrapperHelper.loadOutOfTrx(org.adempiere.model.InterfaceWrapperHelper.loadOutOfTrx) SqlOptions(de.metas.ui.web.window.model.sql.SqlOptions) SqlAndParams(de.metas.ui.web.view.descriptor.SqlAndParams) Page(org.adempiere.util.collections.PagedIterator.Page) HUIdsFilterData(de.metas.ui.web.handlingunits.HUIdsFilterHelper.HUIdsFilterData) PlainContextAware(org.adempiere.model.PlainContextAware) SqlViewSelectData(de.metas.ui.web.view.descriptor.SqlViewSelectData) SQLException(java.sql.SQLException) DB(org.compiere.util.DB) I_M_Product(org.compiere.model.I_M_Product) ImmutableList(com.google.common.collect.ImmutableList) X_M_HU_PI_Version(de.metas.handlingunits.model.X_M_HU_PI_Version) DocumentFilter(de.metas.ui.web.document.filter.DocumentFilter) DocumentQueryOrderBy(de.metas.ui.web.window.model.DocumentQueryOrderBy) I_M_HU(de.metas.handlingunits.model.I_M_HU) LinkedHashSet(java.util.LinkedHashSet) Nullable(javax.annotation.Nullable) DocumentIdsSelection(de.metas.ui.web.window.datatypes.DocumentIdsSelection) JSONLookupValue(de.metas.ui.web.window.datatypes.json.JSONLookupValue) Logger(org.slf4j.Logger) SqlViewKeyColumnNamesMap(de.metas.ui.web.view.descriptor.SqlViewKeyColumnNamesMap) I_C_UOM(org.compiere.model.I_C_UOM) HUPackingInfoFormatter(de.metas.ui.web.handlingunits.util.HUPackingInfoFormatter) WindowId(de.metas.ui.web.window.datatypes.WindowId) ViewRowIdsOrderedSelectionFactory(de.metas.ui.web.view.ViewRowIdsOrderedSelectionFactory) IHandlingUnitsDAO(de.metas.handlingunits.IHandlingUnitsDAO) SqlViewSelectionQueryBuilder(de.metas.ui.web.view.descriptor.SqlViewSelectionQueryBuilder) SqlDocumentFilterConverter(de.metas.ui.web.document.filter.sql.SqlDocumentFilterConverter) Check(org.adempiere.util.Check) IHUProductStorage(de.metas.handlingunits.storage.IHUProductStorage) IHUStorage(de.metas.handlingunits.storage.IHUStorage) ViewId(de.metas.ui.web.view.ViewId) IHandlingUnitsBL(de.metas.handlingunits.IHandlingUnitsBL) JSONLookupValue(de.metas.ui.web.window.datatypes.json.JSONLookupValue) IHUStorageFactory(de.metas.handlingunits.storage.IHUStorageFactory) IHUProductStorage(de.metas.handlingunits.storage.IHUProductStorage) IHandlingUnitsDAO(de.metas.handlingunits.IHandlingUnitsDAO) HUException(de.metas.handlingunits.exceptions.HUException)

Example 30 with WindowId

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);
}
Also used : WindowId(de.metas.ui.web.window.datatypes.WindowId) ViewId(de.metas.ui.web.view.ViewId)

Aggregations

WindowId (de.metas.ui.web.window.datatypes.WindowId)48 DocumentPath (de.metas.ui.web.window.datatypes.DocumentPath)22 JSONDocumentPath (de.metas.ui.web.window.datatypes.json.JSONDocumentPath)13 GetMapping (org.springframework.web.bind.annotation.GetMapping)13 DocumentId (de.metas.ui.web.window.datatypes.DocumentId)9 DocumentEntityDescriptor (de.metas.ui.web.window.descriptor.DocumentEntityDescriptor)9 List (java.util.List)9 Set (java.util.Set)9 ImmutableList (com.google.common.collect.ImmutableList)8 ImmutableSet (com.google.common.collect.ImmutableSet)8 AdempiereException (org.adempiere.exceptions.AdempiereException)8 TableRecordReference (org.adempiere.util.lang.impl.TableRecordReference)8 NonNull (lombok.NonNull)7 Services (org.adempiere.util.Services)7 LogManager (de.metas.logging.LogManager)6 EntityNotFoundException (de.metas.ui.web.exceptions.EntityNotFoundException)6 DetailId (de.metas.ui.web.window.descriptor.DetailId)6 Logger (org.slf4j.Logger)6 Autowired (org.springframework.beans.factory.annotation.Autowired)6 JSONViewDataType (de.metas.ui.web.view.json.JSONViewDataType)5