Search in sources :

Example 1 with I_C_Location

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;
}
Also used : I_C_Location(de.metas.adempiere.model.I_C_Location) DocumentEntityDescriptor(de.metas.ui.web.window.descriptor.DocumentEntityDescriptor) Document(de.metas.ui.web.window.model.Document) AddressFieldBinding(de.metas.ui.web.address.AddressDescriptorFactory.AddressFieldBinding)

Example 2 with I_C_Location

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);
}
Also used : ITrxManager(org.adempiere.ad.trx.api.ITrxManager) ILocationBL(de.metas.adempiere.service.ILocationBL) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) I_C_Location(de.metas.adempiere.model.I_C_Location) Document(de.metas.ui.web.window.model.Document)

Example 3 with I_C_Location

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;
}
Also used : I_C_Location(de.metas.adempiere.model.I_C_Location)

Aggregations

I_C_Location (de.metas.adempiere.model.I_C_Location)3 Document (de.metas.ui.web.window.model.Document)2 ILocationBL (de.metas.adempiere.service.ILocationBL)1 AddressFieldBinding (de.metas.ui.web.address.AddressDescriptorFactory.AddressFieldBinding)1 DocumentId (de.metas.ui.web.window.datatypes.DocumentId)1 DocumentEntityDescriptor (de.metas.ui.web.window.descriptor.DocumentEntityDescriptor)1 ITrxManager (org.adempiere.ad.trx.api.ITrxManager)1