use of de.metas.product.ProductId in project metasfresh-webui-api by metasfresh.
the class MaterialCockpitRowRepository method retrieveRelevantProductIds.
private ImmutableSet<ProductId> retrieveRelevantProductIds(@NonNull final DocumentFilterList filters) {
final OrgId orgId = OrgId.ofRepoIdOrAny(Env.getAD_Org_ID(Env.getCtx()));
final int limit = Services.get(ISysConfigBL.class).getIntValue(SYSCONFIG_EMPTY_PRODUCTS_LIMIT, DEFAULT_EMPTY_PRODUCTS_LIMIT);
final CacheKey cacheKey = new CacheKey(orgId, ProductFilterUtil.extractProductFilterVO(filters), limit);
final ImmutableSet<ProductId> productIds = productFilterVOToProducts.getOrLoad(cacheKey, () -> retrieveProductsFor(cacheKey));
return productIds;
}
use of de.metas.product.ProductId in project metasfresh-webui-api by metasfresh.
the class MaterialCockpitRowRepository method retrieveProductsFor.
private static ImmutableSet<ProductId> retrieveProductsFor(@NonNull final CacheKey cacheKey) {
final OrgId orgId = cacheKey.getOrgId();
final ProductFilterVO productFilterVO = cacheKey.getProductFilterVO();
final int limit = cacheKey.getLimit();
final IQueryFilter<I_M_Product> productQueryFilter = ProductFilterUtil.createProductQueryFilterOrNull(productFilterVO, false);
final IQueryBuilder<I_M_Product> queryBuilder = Services.get(IQueryBL.class).createQueryBuilder(I_M_Product.class).addInArrayFilter(I_M_Product.COLUMNNAME_AD_Org_ID, orgId.getRepoId(), 0).addEqualsFilter(I_M_Product.COLUMN_IsStocked, true).filter(productQueryFilter).orderBy(I_M_Product.COLUMN_Value);
if (limit > 0) {
queryBuilder.setLimit(limit);
}
return queryBuilder.create().listIds(ProductId::ofRepoId);
}
use of de.metas.product.ProductId in project metasfresh-webui-api by metasfresh.
the class HUEditorRowAttributesProvider method createRowAttributes.
private HUEditorRowAttributes createRowAttributes(final ViewRowAttributesKey key) {
final I_M_HU hu = extractHU(key);
final IAttributeStorage attributesStorage = getAttributeStorageFactory().getAttributeStorage(hu);
attributesStorage.setSaveOnChange(true);
final boolean rowAttributesReadonly = // readonly if the provider shall provide readonly attributes
isReadonly() || // or, readonly if not Planning, see https://github.com/metasfresh/metasfresh-webui-api/issues/314
!X_M_HU.HUSTATUS_Planning.equals(hu.getHUStatus());
final IHandlingUnitsBL handlingUnitsBL = Services.get(IHandlingUnitsBL.class);
final IHUStorageFactory storageFactory = handlingUnitsBL.getStorageFactory();
final IHUStorage storage = storageFactory.getStorage(hu);
final ImmutableSet<ProductId> productIDs = storage.getProductStorages().stream().map(IHUProductStorage::getProductId).collect(ImmutableSet.toImmutableSet());
final DocumentPath documentPath = createDocumentPath(key);
return new HUEditorRowAttributes(documentPath, attributesStorage, productIDs, rowAttributesReadonly);
}
use of de.metas.product.ProductId in project metasfresh-webui-api by metasfresh.
the class HUEditorRowId method fromJson.
private static HUEditorRowId fromJson(@NonNull final String json, final DocumentId documentId) {
//
// Split json to parts
final Iterator<String> partsIterator;
{
final List<String> parts = PARTS_SPLITTER.splitToList(json);
if (parts.isEmpty()) {
throw new IllegalArgumentException("Invalid HU rowId: " + json);
}
partsIterator = parts.iterator();
}
//
// huId and storageProductId
final HuId huId;
final ProductId storageProductId;
{
final String idStrPart = partsIterator.next();
final List<String> idParts = ID_SPLITTER.splitToList(idStrPart);
if (idParts.size() == 1) {
huId = HuId.ofRepoId(Integer.parseInt(idParts.get(0)));
storageProductId = null;
} else if (idParts.size() == 2) {
huId = HuId.ofRepoId(Integer.parseInt(idParts.get(0)));
storageProductId = ProductId.ofRepoId(Integer.parseInt(idParts.get(1)));
} else {
throw new IllegalArgumentException("Invalid HU rowId: " + json + ". Cannot parse ID part: " + idStrPart);
}
}
//
// Others
HuId topLevelHUId = null;
while (partsIterator.hasNext()) {
final String part = partsIterator.next();
if (part.startsWith(PREFIX_TopLevelHUId)) {
final String topLevelHUIdStr = part.substring(PREFIX_TopLevelHUId.length());
topLevelHUId = HuId.ofRepoId(Integer.parseInt(topLevelHUIdStr));
} else {
throw new IllegalArgumentException("Invalid HU rowId: " + json + ". Cannot parse part: " + part);
}
}
return new HUEditorRowId(huId, storageProductId, topLevelHUId, json, documentId);
}
use of de.metas.product.ProductId in project metasfresh-webui-api by metasfresh.
the class ProductsToPickRowsDataFactory method createRowFromExistingPickingCandidate.
private ProductsToPickRow createRowFromExistingPickingCandidate(@NonNull final AllocablePackageable packageable, @NonNull final PickingCandidate existingPickingCandidate) {
final PickFrom pickFrom = existingPickingCandidate.getPickFrom();
if (pickFrom.isPickFromHU()) {
final Quantity qty;
final HuId pickFromHUId = pickFrom.getHuId();
if (pickFromHUId != null) {
final ProductId productId = packageable.getProductId();
final ReservableStorage storage = storages.getStorage(pickFromHUId, productId);
qty = storage.reserve(packageable, existingPickingCandidate.getQtyPicked());
} else {
qty = existingPickingCandidate.getQtyPicked();
}
return prepareRow_PickFromHU(packageable).pickFromHUId(pickFromHUId).qty(qty).existingPickingCandidate(existingPickingCandidate).build();
} else if (pickFrom.isPickFromPickingOrder()) {
final ImmutableList<ProductsToPickRow> includedRows = existingPickingCandidate.getIssuesToPickingOrder().stream().map(issueToBOMLine -> prepareRow_IssueComponentsToPickingOrder(toBOMLineAllocablePackageable(issueToBOMLine, packageable)).pickFromHUId(issueToBOMLine.getIssueFromHUId()).qty(issueToBOMLine.getQtyToIssue()).build()).collect(ImmutableList.toImmutableList());
return prepareRow_PickFromPickingOrder(packageable).pickFromPickingOrderId(pickFrom.getPickingOrderId()).qty(existingPickingCandidate.getQtyPicked()).existingPickingCandidate(existingPickingCandidate).includedRows(includedRows).build();
} else {
throw new AdempiereException("Unknown " + pickFrom);
}
}
Aggregations