Search in sources :

Example 1 with I_M_AttributeValue

use of org.compiere.model.I_M_AttributeValue in project metasfresh-webui-api by metasfresh.

the class AvailableToPromiseAdapter method createClientResultGroup0.

private Group createClientResultGroup0(final ResultGroup commonsResultGroup) {
    final GroupBuilder groupBuilder = Group.builder().productId(commonsResultGroup.getProductId());
    final Quantity quantity = Quantity.of(commonsResultGroup.getQty(), retrieveStockingUOM(commonsResultGroup.getProductId()));
    groupBuilder.qty(quantity);
    final AttributesKey attributesKey = commonsResultGroup.getStorageAttributesKey();
    final Type type = extractType(attributesKey);
    groupBuilder.type(type);
    if (type == Type.ATTRIBUTE_SET) {
        final List<I_M_AttributeValue> attributevalues = extractAttributeSetFromStorageAttributesKey(attributesKey);
        groupBuilder.attributeValues(attributevalues);
    }
    return groupBuilder.build();
}
Also used : Type(de.metas.ui.web.material.adapter.AvailableToPromiseResultForWebui.Group.Type) AttributesKey(de.metas.material.event.commons.AttributesKey) GroupBuilder(de.metas.ui.web.material.adapter.AvailableToPromiseResultForWebui.Group.GroupBuilder) Quantity(de.metas.quantity.Quantity) I_M_AttributeValue(org.compiere.model.I_M_AttributeValue)

Example 2 with I_M_AttributeValue

use of org.compiere.model.I_M_AttributeValue in project metasfresh-webui-api by metasfresh.

the class AvailableToPromiseAdapterTests method extractAttributeSetFromStorageAttributesKey.

@Test
public void extractAttributeSetFromStorageAttributesKey() {
    final I_M_Attribute attr1 = attributesTestHelper.createM_Attribute("attr1", X_M_Attribute.ATTRIBUTEVALUETYPE_List, true);
    final I_M_AttributeValue attributeValue1 = attributesTestHelper.createM_AttributeValue(attr1, "value1");
    final I_M_Attribute attr2 = attributesTestHelper.createM_Attribute("attr2", X_M_Attribute.ATTRIBUTEVALUETYPE_List, true);
    final I_M_AttributeValue attributeValue2 = attributesTestHelper.createM_AttributeValue(attr2, "value2");
    // invoke the method under test
    final AttributesKey attributesKey = AttributesKey.ofAttributeValueIds(attributeValue1.getM_AttributeValue_ID(), attributeValue2.getM_AttributeValue_ID());
    final List<I_M_AttributeValue> result = availableToPromiseAdapter.extractAttributeSetFromStorageAttributesKey(attributesKey);
    assertThat(result).hasSize(2);
    assertThat(result).anySatisfy(attributeValue -> {
        assertThatModel(attributeValue).hasSameIdAs(attributeValue1);
        assertThat(attributeValue.getValue()).isEqualTo("value1");
    });
    assertThat(result).anySatisfy(attributeValue -> {
        assertThatModel(attributeValue).hasSameIdAs(attributeValue2);
        assertThat(attributeValue.getValue()).isEqualTo("value2");
    });
}
Also used : AttributesKey(de.metas.material.event.commons.AttributesKey) I_M_Attribute(org.compiere.model.I_M_Attribute) I_M_AttributeValue(org.compiere.model.I_M_AttributeValue) Test(org.junit.Test)

Aggregations

AttributesKey (de.metas.material.event.commons.AttributesKey)2 I_M_AttributeValue (org.compiere.model.I_M_AttributeValue)2 Quantity (de.metas.quantity.Quantity)1 GroupBuilder (de.metas.ui.web.material.adapter.AvailableToPromiseResultForWebui.Group.GroupBuilder)1 Type (de.metas.ui.web.material.adapter.AvailableToPromiseResultForWebui.Group.Type)1 I_M_Attribute (org.compiere.model.I_M_Attribute)1 Test (org.junit.Test)1