use of de.metas.dimension.DimensionSpec in project metasfresh-webui-api by metasfresh.
the class MaterialCockpitRowFactory method createEmptyRowBuckets.
@VisibleForTesting
Map<MainRowBucketId, MainRowWithSubRows> createEmptyRowBuckets(@NonNull final List<I_M_Product> products, @NonNull final Timestamp timestamp) {
final DimensionSpec dimensionSpec = Services.get(IDimensionspecDAO.class).retrieveForInternalNameOrNull(DIM_SPEC_INTERNAL_NAME);
Check.errorIf(dimensionSpec == null, "Unable to load DIM_Dimension_Spec record with InternalName={}", DIM_SPEC_INTERNAL_NAME);
final List<DimensionSpecGroup> groups = dimensionSpec.retrieveGroups();
final List<I_S_Resource> plants = retrieveCountingPlants();
final Builder<MainRowBucketId, MainRowWithSubRows> result = ImmutableMap.builder();
for (final I_M_Product product : products) {
final MainRowBucketId key = MainRowBucketId.createPlainInstance(product.getM_Product_ID(), timestamp);
final MainRowWithSubRows mainRowBucket = MainRowWithSubRows.create(key);
for (final I_S_Resource plant : plants) {
mainRowBucket.addEmptyCountingSubrowBucket(plant.getS_Resource_ID());
}
for (final DimensionSpecGroup group : groups) {
mainRowBucket.addEmptyAttributesSubrowBucket(group);
}
result.put(key, mainRowBucket);
}
return result.build();
}
use of de.metas.dimension.DimensionSpec in project metasfresh-webui-api by metasfresh.
the class MaterialCockpitRowFactory method createRows.
public List<MaterialCockpitRow> createRows(@NonNull final CreateRowsRequest request) {
final Map<MainRowBucketId, MainRowWithSubRows> emptyRowBuckets = createEmptyRowBuckets(request.getProductsToListEvenIfEmpty(), request.getDate());
final DimensionSpec dimensionSpec = Services.get(IDimensionspecDAO.class).retrieveForInternalNameOrNull(DIM_SPEC_INTERNAL_NAME);
Check.errorIf(dimensionSpec == null, "Unable to load DIM_Dimension_Spec record with InternalName={}", DIM_SPEC_INTERNAL_NAME);
final Map<MainRowBucketId, MainRowWithSubRows> result = new HashMap<>(emptyRowBuckets);
addCockpitRowsToResult(request, dimensionSpec, result);
addStockRowsToResult(request, dimensionSpec, result);
return result.values().stream().map(MainRowWithSubRows::createMainRowWithSubRows).collect(ImmutableList.toImmutableList());
}
Aggregations