Search in sources :

Example 11 with Document

use of de.metas.ui.web.window.model.Document in project metasfresh-webui-api by metasfresh.

the class AddressRestController method getAddressDocument.

@RequestMapping(value = "/{docId}", method = RequestMethod.GET)
public JSONDocument getAddressDocument(@PathVariable("docId") final int docId) {
    userSession.assertLoggedIn();
    final Document addressDoc = addressRepo.getAddressDocumentForReading(docId);
    return JSONDocument.ofDocument(addressDoc, newJsonDocumentOpts());
}
Also used : JSONDocument(de.metas.ui.web.window.datatypes.json.JSONDocument) Document(de.metas.ui.web.window.model.Document) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 12 with Document

use of de.metas.ui.web.window.model.Document in project metasfresh-webui-api by metasfresh.

the class AddressRepository method putAddressDocument.

private final void putAddressDocument(final Document addressDoc) {
    final Document addressDocReadonly = addressDoc.copy(CopyMode.CheckInReadonly, NullDocumentChangesCollector.instance);
    id2addressDoc.put(addressDoc.getDocumentId(), addressDocReadonly);
    logger.trace("Added to repository: {}", addressDocReadonly);
}
Also used : Document(de.metas.ui.web.window.model.Document)

Example 13 with Document

use of de.metas.ui.web.window.model.Document 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);
    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(org.compiere.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 14 with Document

use of de.metas.ui.web.window.model.Document in project metasfresh-webui-api by metasfresh.

the class DefaultView method patchViewRow.

@Override
public void patchViewRow(final RowEditingContext ctx, final List<JSONDocumentChangedEvent> fieldChangeRequests) {
    final DocumentId rowId = ctx.getRowId();
    final DocumentCollection documentsCollection = ctx.getDocumentsCollection();
    final DocumentPath documentPath = getById(rowId).getDocumentPath();
    Services.get(ITrxManager.class).runInThreadInheritedTrx(() -> documentsCollection.forDocumentWritable(documentPath, NullDocumentChangesCollector.instance, document -> {
        patchDocument(document, fieldChangeRequests);
        return null;
    }));
    invalidateRowById(rowId);
    ViewChangesCollector.getCurrentOrAutoflush().collectRowChanged(this, rowId);
    documentsCollection.invalidateRootDocument(documentPath);
}
Also used : DocumentValidStatus(de.metas.ui.web.window.model.DocumentValidStatus) DocumentCollection(de.metas.ui.web.window.model.DocumentCollection) ReasonSupplier(de.metas.ui.web.window.model.IDocumentChangesCollector.ReasonSupplier) TableRecordReferenceSet(org.adempiere.util.lang.impl.TableRecordReferenceSet) BigDecimal(java.math.BigDecimal) Evaluatee(org.compiere.util.Evaluatee) Page(de.metas.util.collections.PagedIterator.Page) DocumentFilterList(de.metas.ui.web.document.filter.DocumentFilterList) ImmutableSet(com.google.common.collect.ImmutableSet) DocumentQueryOrderByList(de.metas.ui.web.window.model.DocumentQueryOrderByList) ITranslatableString(de.metas.i18n.ITranslatableString) NonNull(lombok.NonNull) Collection(java.util.Collection) Set(java.util.Set) ITrxManager(org.adempiere.ad.trx.api.ITrxManager) Objects(java.util.Objects) EntityNotFoundException(de.metas.ui.web.exceptions.EntityNotFoundException) List(java.util.List) Stream(java.util.stream.Stream) DocumentFieldWidgetType(de.metas.ui.web.window.descriptor.DocumentFieldWidgetType) TranslatableStrings(de.metas.i18n.TranslatableStrings) LogManager(de.metas.logging.LogManager) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) Getter(lombok.Getter) JSONDocumentChangedEvent(de.metas.ui.web.window.datatypes.json.JSONDocumentChangedEvent) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) SqlOptions(de.metas.ui.web.window.model.sql.SqlOptions) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) JSONViewDataType(de.metas.ui.web.view.json.JSONViewDataType) NullDocumentChangesCollector(de.metas.ui.web.window.model.NullDocumentChangesCollector) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) FacetFilterViewCacheMap(de.metas.ui.web.document.filter.provider.standard.FacetFilterViewCacheMap) IteratorUtils(de.metas.util.collections.IteratorUtils) ImmutableList(com.google.common.collect.ImmutableList) DocumentFilter(de.metas.ui.web.document.filter.DocumentFilter) LookupValuesList(de.metas.ui.web.window.datatypes.LookupValuesList) Nullable(javax.annotation.Nullable) DocumentIdsSelection(de.metas.ui.web.window.datatypes.DocumentIdsSelection) Logger(org.slf4j.Logger) MoreObjects(com.google.common.base.MoreObjects) DocumentFilterDescriptorsProvider(de.metas.ui.web.document.filter.provider.DocumentFilterDescriptorsProvider) DocumentSaveStatus(de.metas.ui.web.window.model.DocumentSaveStatus) CCache(de.metas.cache.CCache) Services(de.metas.util.Services) NumberUtils(de.metas.util.NumberUtils) Consumer(java.util.function.Consumer) AdempiereException(org.adempiere.exceptions.AdempiereException) ViewChangesCollector(de.metas.ui.web.view.event.ViewChangesCollector) Document(de.metas.ui.web.window.model.Document) ITrxManager(org.adempiere.ad.trx.api.ITrxManager) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) DocumentCollection(de.metas.ui.web.window.model.DocumentCollection)

Example 15 with Document

use of de.metas.ui.web.window.model.Document in project metasfresh-webui-api by metasfresh.

the class WindowRestController method processRecord.

/**
 * @task https://github.com/metasfresh/metasfresh/issues/1090
 */
@GetMapping("/{windowId}/{documentId}/processNewRecord")
public int processRecord(// 
@PathVariable("windowId") final String windowIdStr, // 
@PathVariable("documentId") final String documentIdStr) {
    userSession.assertLoggedIn();
    final WindowId windowId = WindowId.fromJson(windowIdStr);
    final DocumentPath documentPath = DocumentPath.rootDocumentPath(windowId, documentIdStr);
    final IDocumentChangesCollector changesCollector = NullDocumentChangesCollector.instance;
    return Execution.callInNewExecution("window.processTemplate", () -> documentCollection.forDocumentWritable(documentPath, changesCollector, document -> {
        document.saveIfValidAndHasChanges();
        if (document.hasChangesRecursivelly()) {
            throw new AdempiereException("Not saved");
        }
        final int newRecordId = newRecordDescriptorsProvider.getNewRecordDescriptor(document.getEntityDescriptor()).getProcessor().processNewRecordDocument(document);
        return newRecordId;
    }));
}
Also used : PathVariable(org.springframework.web.bind.annotation.PathVariable) RequestParam(org.springframework.web.bind.annotation.RequestParam) DisplayPlace(de.metas.process.RelatedProcessDescriptor.DisplayPlace) WebRequest(org.springframework.web.context.request.WebRequest) DocumentZoomIntoInfo(de.metas.ui.web.window.model.lookup.DocumentZoomIntoInfo) Autowired(org.springframework.beans.factory.annotation.Autowired) ApiParam(io.swagger.annotations.ApiParam) JSONZoomInto(de.metas.ui.web.window.datatypes.json.JSONZoomInto) DocumentCollection(de.metas.ui.web.window.model.DocumentCollection) DocumentChangeLogService(de.metas.ui.web.window.model.DocumentChangeLogService) ReasonSupplier(de.metas.ui.web.window.model.IDocumentChangesCollector.ReasonSupplier) JSONDocumentChangeLog(de.metas.ui.web.window.datatypes.json.JSONDocumentChangeLog) ApiOperation(io.swagger.annotations.ApiOperation) DocumentWebsocketPublisher(de.metas.ui.web.window.events.DocumentWebsocketPublisher) IDocumentFieldView(de.metas.ui.web.window.model.IDocumentFieldView) JSONDocumentReferencesGroupList(de.metas.ui.web.window.datatypes.json.JSONDocumentReferencesGroupList) DocumentReference(de.metas.ui.web.window.model.DocumentReference) TableRecordReference(org.adempiere.util.lang.impl.TableRecordReference) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping) PostMapping(org.springframework.web.bind.annotation.PostMapping) ImmutableSet(com.google.common.collect.ImmutableSet) JSONDocumentLayoutOptions(de.metas.ui.web.window.datatypes.json.JSONDocumentLayoutOptions) DocumentQueryOrderByList(de.metas.ui.web.window.model.DocumentQueryOrderByList) Predicate(java.util.function.Predicate) HttpHeaders(org.springframework.http.HttpHeaders) NonNull(lombok.NonNull) MediaType(org.springframework.http.MediaType) DocumentDescriptor(de.metas.ui.web.window.descriptor.DocumentDescriptor) Set(java.util.Set) ProcessRestController(de.metas.ui.web.process.ProcessRestController) RestController(org.springframework.web.bind.annotation.RestController) JSONLookupValuesList(de.metas.ui.web.window.datatypes.json.JSONLookupValuesList) UserSession(de.metas.ui.web.session.UserSession) DocumentFieldDescriptor(de.metas.ui.web.window.descriptor.DocumentFieldDescriptor) EntityNotFoundException(de.metas.ui.web.exceptions.EntityNotFoundException) List(java.util.List) DocumentPrint(de.metas.ui.web.window.model.DocumentCollection.DocumentPrint) IDocumentChangesCollector(de.metas.ui.web.window.model.IDocumentChangesCollector) DocumentFieldWidgetType(de.metas.ui.web.window.descriptor.DocumentFieldWidgetType) IMsgBL(de.metas.i18n.IMsgBL) MenuTreeRepository(de.metas.ui.web.menu.MenuTreeRepository) JSONDocument(de.metas.ui.web.window.datatypes.json.JSONDocument) IADTableDAO(org.adempiere.ad.table.api.IADTableDAO) JSONOptions(de.metas.ui.web.window.datatypes.json.JSONOptions) DocumentReferencesService(de.metas.ui.web.window.model.DocumentReferencesService) WebConfig(de.metas.ui.web.config.WebConfig) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) JSONDocumentChangedEvent(de.metas.ui.web.window.datatypes.json.JSONDocumentChangedEvent) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ButtonFieldActionDescriptor(de.metas.ui.web.window.descriptor.ButtonFieldActionDescriptor) MenuTree(de.metas.ui.web.menu.MenuTree) PatchMapping(org.springframework.web.bind.annotation.PatchMapping) NullDocumentChangesCollector(de.metas.ui.web.window.model.NullDocumentChangesCollector) RequestBody(org.springframework.web.bind.annotation.RequestBody) ImmutableList(com.google.common.collect.ImmutableList) DetailId(de.metas.ui.web.window.descriptor.DetailId) DocumentEntityDescriptor(de.metas.ui.web.window.descriptor.DocumentEntityDescriptor) GetMapping(org.springframework.web.bind.annotation.GetMapping) JSONDocumentOptions(de.metas.ui.web.window.datatypes.json.JSONDocumentOptions) LookupValuesList(de.metas.ui.web.window.datatypes.LookupValuesList) JSONDocumentReferencesGroup(de.metas.ui.web.window.datatypes.json.JSONDocumentReferencesGroup) NewRecordDescriptorsProvider(de.metas.ui.web.window.descriptor.factory.NewRecordDescriptorsProvider) Api(io.swagger.annotations.Api) Nullable(javax.annotation.Nullable) DocumentIdsSelection(de.metas.ui.web.window.datatypes.DocumentIdsSelection) JSONDocumentPath(de.metas.ui.web.window.datatypes.json.JSONDocumentPath) WindowId(de.metas.ui.web.window.datatypes.WindowId) ETagResponseEntityBuilder(de.metas.ui.web.cache.ETagResponseEntityBuilder) WebuiRelatedProcessDescriptor(de.metas.ui.web.process.descriptor.WebuiRelatedProcessDescriptor) Services(de.metas.util.Services) HttpStatus(org.springframework.http.HttpStatus) JSONDocumentActionsList(de.metas.ui.web.process.json.JSONDocumentActionsList) DocumentPreconditionsAsContext(de.metas.ui.web.process.DocumentPreconditionsAsContext) AdempiereException(org.adempiere.exceptions.AdempiereException) JSONDocumentReference(de.metas.ui.web.window.datatypes.json.JSONDocumentReference) JSONOptionsBuilder(de.metas.ui.web.window.datatypes.json.JSONOptions.JSONOptionsBuilder) ResponseEntity(org.springframework.http.ResponseEntity) JSONDocumentLayout(de.metas.ui.web.window.datatypes.json.JSONDocumentLayout) JSONDocumentLayoutOptionsBuilder(de.metas.ui.web.window.datatypes.json.JSONDocumentLayoutOptions.JSONDocumentLayoutOptionsBuilder) Document(de.metas.ui.web.window.model.Document) JSONDocumentOptionsBuilder(de.metas.ui.web.window.datatypes.json.JSONDocumentOptions.JSONDocumentOptionsBuilder) WindowId(de.metas.ui.web.window.datatypes.WindowId) AdempiereException(org.adempiere.exceptions.AdempiereException) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) JSONDocumentPath(de.metas.ui.web.window.datatypes.json.JSONDocumentPath) IDocumentChangesCollector(de.metas.ui.web.window.model.IDocumentChangesCollector) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

Document (de.metas.ui.web.window.model.Document)36 DocumentId (de.metas.ui.web.window.datatypes.DocumentId)16 DocumentPath (de.metas.ui.web.window.datatypes.DocumentPath)12 IDocumentChangesCollector (de.metas.ui.web.window.model.IDocumentChangesCollector)10 List (java.util.List)9 Set (java.util.Set)9 AdempiereException (org.adempiere.exceptions.AdempiereException)9 ImmutableList (com.google.common.collect.ImmutableList)8 DocumentEntityDescriptor (de.metas.ui.web.window.descriptor.DocumentEntityDescriptor)8 ImmutableSet (com.google.common.collect.ImmutableSet)7 EntityNotFoundException (de.metas.ui.web.exceptions.EntityNotFoundException)6 WindowConstants (de.metas.ui.web.window.WindowConstants)6 Services (de.metas.util.Services)6 ArrayList (java.util.ArrayList)6 Map (java.util.Map)6 JSONDocument (de.metas.ui.web.window.datatypes.json.JSONDocument)5 DocumentSaveStatus (de.metas.ui.web.window.model.DocumentSaveStatus)5 Collectors (java.util.stream.Collectors)5 NonNull (lombok.NonNull)5 JsonIgnore (com.fasterxml.jackson.annotation.JsonIgnore)4