use of de.metas.ui.web.window.datatypes.DocumentId in project metasfresh-webui-api by metasfresh.
the class MenuTreeLoader method createMenuNodeBuilder.
private MenuNode.Builder createMenuNodeBuilder(final MTreeNode nodeModel, final int depth) {
// shall not be empty
final String captionBreadcrumb = nodeModel.getName();
String caption = nodeModel.getWEBUI_NameBrowse();
if (Check.isEmpty(caption, true)) {
caption = captionBreadcrumb;
}
final MenuNode.Builder builder = MenuNode.builder().setAD_Menu_ID(nodeModel.getNode_ID()).setCaption(caption).setCaptionBreadcrumb(captionBreadcrumb).setMainTableName(nodeModel.getMainTableName());
final String action = nodeModel.getImageIndiactor();
if (nodeModel.isSummary()) {
builder.setTypeGroup();
} else if (depth == DEPTH_RootChildren) {
logger.warn("Skip creating leaf nodes for root: {}", nodeModel);
return null;
} else if (X_AD_Menu.ACTION_Window.equals(action)) {
final DocumentId elementId = DocumentId.of(nodeModel.getAD_Window_ID());
builder.setType(MenuNodeType.Window, elementId);
} else if (X_AD_Menu.ACTION_Process.equals(action)) {
final DocumentId elementId = ProcessId.ofAD_Process_ID(nodeModel.getAD_Process_ID()).toDocumentId();
builder.setType(MenuNodeType.Process, elementId);
} else if (X_AD_Menu.ACTION_Report.equals(action)) {
final DocumentId elementId = ProcessId.ofAD_Process_ID(nodeModel.getAD_Process_ID()).toDocumentId();
builder.setType(MenuNodeType.Report, elementId);
} else if (X_AD_Menu.ACTION_Board.equals(action)) {
final DocumentId elementId = DocumentId.of(nodeModel.getWEBUI_Board_ID());
builder.setType(MenuNodeType.Board, elementId);
} else {
return null;
}
return builder;
}
use of de.metas.ui.web.window.datatypes.DocumentId in project metasfresh-webui-api by metasfresh.
the class HUReportProcessInstancesRepository method createNewProcessInstance.
@Override
public HUReportProcessInstance createNewProcessInstance(final CreateProcessInstanceRequest request) {
final WebuiHUProcessDescriptor descriptor = getWebuiHUProcessDescriptor(request.getProcessId());
final DocumentId instanceId = nextPInstanceId();
final Document parameters = Document.builder(descriptor.getParametersDescriptor()).initializeAsNewDocument(instanceId, /* version */
"0");
final HUReportProcessInstance instance = HUReportProcessInstance.builder().instanceId(instanceId).viewRowIdsSelection(request.getViewRowIdsSelection()).reportADProcessId(descriptor.getReportADProcessId()).parameters(parameters).build();
instance.setCopies(1);
putInstance(instance);
return instance;
}
use of de.metas.ui.web.window.datatypes.DocumentId in project metasfresh-webui-api by metasfresh.
the class HUEditorRowAttributesProvider method createRowAttributes.
private HUEditorRowAttributes createRowAttributes(final ViewRowAttributesKey key) {
final int huId = key.getHuId().toInt();
final I_M_HU hu = InterfaceWrapperHelper.create(Env.getCtx(), huId, I_M_HU.class, ITrx.TRXNAME_None);
if (hu == null) {
throw new IllegalArgumentException("No HU found for M_HU_ID=" + huId);
}
final IAttributeStorage attributesStorage = getAttributeStorageFactory().getAttributeStorage(hu);
attributesStorage.setSaveOnChange(true);
final DocumentId documentTypeId = DocumentId.of(huId);
final DocumentId huEditorRowId = key.getHuEditorRowId();
final DocumentPath documentPath = DocumentPath.rootDocumentPath(DocumentType.ViewRecordAttributes, documentTypeId, huEditorRowId);
final boolean rowAttributesReadonly = // readonly if the provider shall provide readonly attributes
isReadonly() || // or, readonly if not Planning, see https://github.com/metasfresh/metasfresh-webui-api/issues/314
!X_M_HU.HUSTATUS_Planning.equals(hu.getHUStatus());
return new HUEditorRowAttributes(documentPath, attributesStorage, rowAttributesReadonly);
}
use of de.metas.ui.web.window.datatypes.DocumentId in project metasfresh-webui-api by metasfresh.
the class WEBUI_M_ReceiptSchedule_CreateEmptiesReturns_Base method createDraftEmptiesDocument.
private int createDraftEmptiesDocument() {
final DocumentPath documentPath = DocumentPath.builder().setDocumentType(WindowId.of(getTargetWindowId())).setDocumentId(DocumentId.NEW_ID_STRING).allowNewDocumentId().build();
final DocumentId documentId = documentsRepo.forDocumentWritable(documentPath, NullDocumentChangesCollector.instance, document -> {
huEmptiesService.newReturnsInOutProducer(getCtx()).setMovementType(getReturnMovementType()).setMovementDate(SystemTime.asDayTimestamp()).fillReturnsInOutHeader(InterfaceWrapperHelper.create(document, I_M_InOut.class));
return document.getDocumentId();
});
return documentId.toInt();
}
use of de.metas.ui.web.window.datatypes.DocumentId in project metasfresh-webui-api by metasfresh.
the class PurchaseRowIdTest method fromDocumentId_NotAvailable.
@Test
public void fromDocumentId_NotAvailable() {
final DocumentId documentId = DocumentId.ofString("1000007-2156423-32311-NOT_AVAILABLE-11");
final PurchaseRowId purchaseRowId = PurchaseRowId.fromDocumentId(documentId);
assertThat(purchaseRowId.getSalesOrderLineId()).isEqualTo(1000007);
assertThat(purchaseRowId.getVendorBPartnerId()).isEqualTo(2156423);
assertThat(purchaseRowId.getProcessedPurchaseCandidateId()).isEqualTo(32311);
assertThat(purchaseRowId.getAvailabilityType()).isEqualTo(Type.NOT_AVAILABLE);
}
Aggregations