use of de.metas.handlingunits.attribute.storage.IAttributeStorage in project metasfresh-webui-api by metasfresh.
the class WEBUIHUCreationWithSerialNumberService method getAttributeStorage.
private final IAttributeStorage getAttributeStorage(final IHUContext huContext, final I_M_HU hu) {
final IAttributeStorageFactory attributeStorageFactory = huContext.getHUAttributeStorageFactory();
final IAttributeStorage attributeStorage = attributeStorageFactory.getAttributeStorage(hu);
return attributeStorage;
}
use of de.metas.handlingunits.attribute.storage.IAttributeStorage in project metasfresh-webui-api by metasfresh.
the class HUEditorRowAttributesProvider method createRowAttributes.
private HUEditorRowAttributes createRowAttributes(final ViewRowAttributesKey key) {
final int huId = key.getHuId().toInt();
final I_M_HU hu = InterfaceWrapperHelper.create(Env.getCtx(), huId, I_M_HU.class, ITrx.TRXNAME_None);
if (hu == null) {
throw new IllegalArgumentException("No HU found for M_HU_ID=" + huId);
}
final IAttributeStorage attributesStorage = getAttributeStorageFactory().getAttributeStorage(hu);
attributesStorage.setSaveOnChange(true);
final DocumentId documentTypeId = DocumentId.of(huId);
final DocumentId huEditorRowId = key.getHuEditorRowId();
final DocumentPath documentPath = DocumentPath.rootDocumentPath(DocumentType.ViewRecordAttributes, documentTypeId, huEditorRowId);
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());
return new HUEditorRowAttributes(documentPath, attributesStorage, rowAttributesReadonly);
}
use of de.metas.handlingunits.attribute.storage.IAttributeStorage in project metasfresh-webui-api by metasfresh.
the class WEBUIHUCreationWithSerialNumberService method assignSerialNumberToCU.
private void assignSerialNumberToCU(final int huId, final String serialNo) {
final I_M_HU hu = create(Env.getCtx(), huId, I_M_HU.class, ITrx.TRXNAME_ThreadInherited);
final IContextAware ctxAware = getContextAware(hu);
final IHUContext huContext = handlingUnitsBL.createMutableHUContext(ctxAware);
final IAttributeStorage attributeStorage = getAttributeStorage(huContext, hu);
final I_M_Attribute serialNoAttribute = serialNoDAO.getSerialNoAttribute(ctxAware.getCtx());
Check.errorUnless(attributeStorage.hasAttribute(serialNoAttribute), "There is no SerialNo attribute {} defined for the handling unit {}", serialNoAttribute, hu);
attributeStorage.setValue(serialNoAttribute, serialNo.trim());
attributeStorage.saveChangesIfNeeded();
}
Aggregations