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();
}
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);
}
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;
}
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;
}
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);
}
Aggregations