use of de.metas.adempiere.model.I_C_Location in project metasfresh-webui-api by metasfresh.
the class AddressRepository method createNewFrom.
public Document createNewFrom(final int fromC_Location_ID) {
final DocumentEntityDescriptor entityDescriptor = descriptorsFactory.getAddressDescriptor().getEntityDescriptor();
final Document addressDoc = Document.builder(entityDescriptor).initializeAsNewDocument(nextAddressDocId::getAndIncrement, VERSION_DEFAULT).build();
final I_C_Location fromLocation = fromC_Location_ID <= 0 ? null : InterfaceWrapperHelper.create(Env.getCtx(), fromC_Location_ID, I_C_Location.class, ITrx.TRXNAME_ThreadInherited);
if (fromLocation != null) {
addressDoc.getFieldViews().stream().forEach(field -> {
final Object value = field.getDescriptor().getDataBindingNotNull(AddressFieldBinding.class).readValue(fromLocation);
addressDoc.processValueChange(field.getFieldName(), value, () -> "update from " + fromLocation);
});
}
addressDoc.checkAndGetValidStatus();
logger.trace("Created from C_Location_ID={}: {}", fromC_Location_ID, addressDoc);
putAddressDocument(addressDoc);
return addressDoc;
}
use of de.metas.adempiere.model.I_C_Location in project metasfresh-webui-api by metasfresh.
the class AddressRepository method complete.
public LookupValue complete(final int addressDocIdInt) {
final DocumentId addressDocId = DocumentId.of(addressDocIdInt);
final Document addressDoc = getAddressDocumentForWriting(addressDocId, NullDocumentChangesCollector.instance);
final I_C_Location locationRecord = createC_Location(addressDoc);
Services.get(ITrxManager.class).getCurrentTrxListenerManagerOrAutoCommit().newEventListener(TrxEventTiming.AFTER_COMMIT).registerHandlingMethod(trx -> removeAddressDocumentById(addressDocId));
final String locationStr = Services.get(ILocationBL.class).mkAddress(locationRecord);
return IntegerLookupValue.of(locationRecord.getC_Location_ID(), locationStr);
}
use of de.metas.adempiere.model.I_C_Location in project metasfresh-webui-api by metasfresh.
the class AddressRepository method createC_Location.
private final I_C_Location createC_Location(final Document locationDoc) {
final I_C_Location locationRecord = InterfaceWrapperHelper.create(Env.getCtx(), I_C_Location.class, ITrx.TRXNAME_ThreadInherited);
locationDoc.getFieldViews().stream().forEach(locationField -> locationField.getDescriptor().getDataBindingNotNull(AddressFieldBinding.class).writeValue(locationRecord, locationField));
InterfaceWrapperHelper.save(locationRecord);
return locationRecord;
}
Aggregations