Search in sources :

Example 6 with DocumentEntityDescriptor

use of de.metas.ui.web.window.descriptor.DocumentEntityDescriptor in project metasfresh-webui-api by metasfresh.

the class ViewActionDescriptor method getProcessDescriptor.

public ProcessDescriptor getProcessDescriptor(@NonNull final ProcessId processId) {
    final DocumentEntityDescriptor parametersDescriptor = createParametersEntityDescriptor(processId);
    final ProcessLayout processLayout = ProcessLayout.builder().setProcessId(processId).setLayoutType(layoutType).setCaption(caption).setDescription(description).addElements(parametersDescriptor).build();
    return ProcessDescriptor.builder().setProcessId(processId).setType(ProcessDescriptorType.Process).setLayout(processLayout).build();
}
Also used : ProcessLayout(de.metas.ui.web.process.descriptor.ProcessLayout) DocumentEntityDescriptor(de.metas.ui.web.window.descriptor.DocumentEntityDescriptor)

Example 7 with DocumentEntityDescriptor

use of de.metas.ui.web.window.descriptor.DocumentEntityDescriptor in project metasfresh-webui-api by metasfresh.

the class AddressDescriptorFactory method createAddressDescriptor.

private AddressDescriptor createAddressDescriptor() {
    final DocumentEntityDescriptor entityDescriptor = createAddressEntityDescriptor();
    final AddressLayout layout = createLayout(entityDescriptor);
    return AddressDescriptor.of(entityDescriptor, layout);
}
Also used : DocumentEntityDescriptor(de.metas.ui.web.window.descriptor.DocumentEntityDescriptor)

Example 8 with DocumentEntityDescriptor

use of de.metas.ui.web.window.descriptor.DocumentEntityDescriptor 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 9 with DocumentEntityDescriptor

use of de.metas.ui.web.window.descriptor.DocumentEntityDescriptor in project metasfresh-webui-api by metasfresh.

the class DocumentCollection method createRootDocument.

/**
 * Creates a new root document.
 *
 * @param documentPath
 * @return new root document (writable)
 */
private Document createRootDocument(final DocumentPath documentPath, final IDocumentChangesCollector changesCollector) {
    if (!documentPath.isNewDocument()) {
        throw new InvalidDocumentPathException(documentPath, "new document ID was expected");
    }
    final WindowId windowId = documentPath.getWindowId();
    final DocumentEntityDescriptor entityDescriptor = getDocumentEntityDescriptor(windowId);
    assertNewDocumentAllowed(entityDescriptor);
    final DocumentsRepository documentsRepository = entityDescriptor.getDataBinding().getDocumentsRepository();
    final Document document = documentsRepository.createNewDocument(entityDescriptor, Document.NULL, changesCollector);
    // NOTE: we are not adding it to index. That shall be done on "commit".
    return document;
}
Also used : WindowId(de.metas.ui.web.window.datatypes.WindowId) DocumentEntityDescriptor(de.metas.ui.web.window.descriptor.DocumentEntityDescriptor) SourceDocument(de.metas.letters.model.MADBoilerPlate.SourceDocument) InvalidDocumentPathException(de.metas.ui.web.window.exceptions.InvalidDocumentPathException)

Example 10 with DocumentEntityDescriptor

use of de.metas.ui.web.window.descriptor.DocumentEntityDescriptor in project metasfresh-webui-api by metasfresh.

the class DocumentCollection method invalidateIncludedDocumentsByRecordId.

public void invalidateIncludedDocumentsByRecordId(final String tableName, final int recordId, final String childTableName, final int childRecordId) {
    final DocumentId documentId = DocumentId.of(recordId);
    final DocumentId rowId = childRecordId > 0 ? DocumentId.of(childRecordId) : null;
    final Function<DocumentEntityDescriptor, DocumentPath> toDocumentPath;
    if (rowId != null) {
        toDocumentPath = includedEntity -> DocumentPath.includedDocumentPath(includedEntity.getWindowId(), documentId, includedEntity.getDetailId(), rowId);
    } else {
        // all rows for given tab/detail
        toDocumentPath = includedEntity -> DocumentPath.includedDocumentPath(includedEntity.getWindowId(), documentId, includedEntity.getDetailId());
    }
    // 
    // Create possible documentKeys for given tableName/recordId
    final ImmutableSet<DocumentPath> documentPaths = getCachedWindowIdsForTableName(tableName).stream().map(this::getDocumentEntityDescriptor).flatMap(rootEntity -> rootEntity.streamIncludedEntitiesByTableName(childTableName)).map(toDocumentPath).collect(ImmutableSet.toImmutableSet());
    documentPaths.forEach(this::invalidateIncludedDocuments);
}
Also used : DocumentId(de.metas.ui.web.window.datatypes.DocumentId) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) DocumentEntityDescriptor(de.metas.ui.web.window.descriptor.DocumentEntityDescriptor)

Aggregations

DocumentEntityDescriptor (de.metas.ui.web.window.descriptor.DocumentEntityDescriptor)33 DocumentPath (de.metas.ui.web.window.datatypes.DocumentPath)9 WindowId (de.metas.ui.web.window.datatypes.WindowId)8 DocumentId (de.metas.ui.web.window.datatypes.DocumentId)7 ArrayList (java.util.ArrayList)5 NonNull (lombok.NonNull)5 AdempiereException (org.adempiere.exceptions.AdempiereException)5 Services (org.adempiere.util.Services)5 ImmutableList (com.google.common.collect.ImmutableList)4 IMsgBL (de.metas.i18n.IMsgBL)4 ProcessId (de.metas.ui.web.process.ProcessId)4 QuickInputLayoutDescriptor (de.metas.ui.web.quickinput.QuickInputLayoutDescriptor)4 ViewId (de.metas.ui.web.view.ViewId)4 SqlDocumentEntityDataBindingDescriptor (de.metas.ui.web.window.descriptor.sql.SqlDocumentEntityDataBindingDescriptor)4 Document (de.metas.ui.web.window.model.Document)4 List (java.util.List)4 Env (org.compiere.util.Env)4 ITranslatableString (de.metas.i18n.ITranslatableString)3 SourceDocument (de.metas.letters.model.MADBoilerPlate.SourceDocument)3 EntityNotFoundException (de.metas.ui.web.exceptions.EntityNotFoundException)3