use of org.compiere.model.I_M_Attribute in project metasfresh-webui-api by metasfresh.
the class ASIDescriptorFactory method createDocumentEntityDescriptor.
private final //
DocumentEntityDescriptor createDocumentEntityDescriptor(//
DocumentId asiDescriptorId, //
final String name, //
final String description, //
final List<MAttribute> attributes) {
if (attributes.isEmpty()) {
throw new AdempiereException("No attributes are configured").setParameter("asiDescriptorId", asiDescriptorId);
}
final DocumentEntityDescriptor.Builder attributeSetDescriptor = DocumentEntityDescriptor.builder().setDocumentType(DocumentType.ProductAttributes, asiDescriptorId).setCaption(name).setDescription(description).setDataBinding(getASIBindingsBuilder()).disableCallouts().setDetailId(null);
for (final I_M_Attribute attribute : attributes) {
final DocumentFieldDescriptor.Builder fieldDescriptor = createDocumentFieldDescriptor(attribute);
attributeSetDescriptor.addField(fieldDescriptor);
}
return attributeSetDescriptor.build();
}
use of org.compiere.model.I_M_Attribute in project metasfresh-webui-api by metasfresh.
the class HUEditorRowAttributes method processChange.
private void processChange(final JSONDocumentChangedEvent event) {
if (JSONDocumentChangedEvent.JSONOperation.replace == event.getOperation()) {
final String attributeName = event.getPath();
if (isReadonly(attributeName)) {
throw new DocumentFieldReadonlyException(attributeName, event.getValue());
}
final I_M_Attribute attribute = attributesStorage.getAttributeByValueKeyOrNull(attributeName);
final Object value = convertFromJson(attribute, event.getValue());
attributesStorage.setValue(attribute, value);
} else {
throw new IllegalArgumentException("Unknown operation: " + event);
}
}
use of org.compiere.model.I_M_Attribute in project metasfresh-webui-api by metasfresh.
the class HUEditorRowAttributes method getBestBeforeDate.
public Optional<Date> getBestBeforeDate() {
final I_M_Attribute bestBeforeDateAttribute = Services.get(IAttributeDAO.class).retrieveAttributeByValue(Constants.ATTR_BestBeforeDate);
if (!attributesStorage.hasAttribute(bestBeforeDateAttribute)) {
return Optional.empty();
}
Date bestBeforeDate = attributesStorage.getValueAsDate(bestBeforeDateAttribute);
return Optional.ofNullable(bestBeforeDate);
}
use of org.compiere.model.I_M_Attribute in project metasfresh-webui-api by metasfresh.
the class HUEditorRowAttributes method getSSCC18.
public Optional<String> getSSCC18() {
final I_M_Attribute sscc18Attribute = Services.get(ISSCC18CodeDAO.class).retrieveSSCC18Attribute(Env.getCtx());
if (!attributesStorage.hasAttribute(sscc18Attribute)) {
return Optional.empty();
}
final String sscc18 = attributesStorage.getValueAsString(sscc18Attribute);
if (Check.isEmpty(sscc18, true)) {
return Optional.empty();
}
return Optional.of(sscc18.trim());
}
use of org.compiere.model.I_M_Attribute 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");
});
}
Aggregations