Search in sources :

Example 6 with DocumentId

use of de.metas.ui.web.window.datatypes.DocumentId in project metasfresh-webui-api by metasfresh.

the class QuickInputDescriptorFactoryService method hasQuickInputEntityDescriptor.

public boolean hasQuickInputEntityDescriptor(@NonNull final DocumentEntityDescriptor includedDocumentDescriptor) {
    final DocumentType documentType = includedDocumentDescriptor.getDocumentType();
    final DocumentId documentTypeId = includedDocumentDescriptor.getDocumentTypeId();
    final String tableName = includedDocumentDescriptor.getTableNameOrNull();
    final DetailId detailId = includedDocumentDescriptor.getDetailId();
    final Optional<Boolean> soTrx = includedDocumentDescriptor.getIsSOTrx();
    return getQuickInputEntityDescriptorOrNull(documentType, documentTypeId, tableName, detailId, soTrx) != null;
}
Also used : DetailId(de.metas.ui.web.window.descriptor.DetailId) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) DocumentType(de.metas.ui.web.window.datatypes.DocumentType)

Example 7 with DocumentId

use of de.metas.ui.web.window.datatypes.DocumentId in project metasfresh-webui-api by metasfresh.

the class QuickInputPath method of.

public static final // 
QuickInputPath of(// 
final String windowIdStr, // 
final String documentIdStr, // 
final String tabIdStr, // 
final String quickInputIdStr) {
    final DocumentPath rootDocumentPath = DocumentPath.rootDocumentPath(WindowId.fromJson(windowIdStr), documentIdStr);
    final DetailId detailId = DetailId.fromJson(tabIdStr);
    final DocumentId quickInputId = DocumentId.of(quickInputIdStr);
    return new QuickInputPath(rootDocumentPath, detailId, quickInputId);
}
Also used : DetailId(de.metas.ui.web.window.descriptor.DetailId) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath)

Example 8 with DocumentId

use of de.metas.ui.web.window.datatypes.DocumentId in project metasfresh-webui-api by metasfresh.

the class JSONCreateProcessInstanceRequest method createSelectedIncludedDocumentPaths.

private static final List<DocumentPath> createSelectedIncludedDocumentPaths(final WindowId windowId, final String documentIdStr, final JSONSelectedIncludedTab selectedTab) {
    if (windowId == null || Check.isEmpty(documentIdStr, true) || selectedTab == null) {
        return ImmutableList.of();
    }
    final DocumentId documentId = DocumentId.of(documentIdStr);
    final DetailId selectedTabId = DetailId.fromJson(selectedTab.getTabId());
    return selectedTab.getRowIds().stream().map(DocumentId::of).map(rowId -> DocumentPath.includedDocumentPath(windowId, documentId, selectedTabId, rowId)).collect(ImmutableList.toImmutableList());
}
Also used : JsonProperty(com.fasterxml.jackson.annotation.JsonProperty) ViewRowIdsSelection(de.metas.ui.web.view.ViewRowIdsSelection) ImmutableSet(com.google.common.collect.ImmutableSet) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) NonNull(lombok.NonNull) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) Set(java.util.Set) Visibility(com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility) MoreObjects(com.google.common.base.MoreObjects) WindowId(de.metas.ui.web.window.datatypes.WindowId) JsonAutoDetect(com.fasterxml.jackson.annotation.JsonAutoDetect) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) ProcessId(de.metas.ui.web.process.ProcessId) Check(de.metas.printing.esb.base.util.Check) JsonCreator(com.fasterxml.jackson.annotation.JsonCreator) JsonIgnore(com.fasterxml.jackson.annotation.JsonIgnore) DetailId(de.metas.ui.web.window.descriptor.DetailId) Data(lombok.Data) JsonInclude(com.fasterxml.jackson.annotation.JsonInclude) ViewId(de.metas.ui.web.view.ViewId) DocumentIdsSelection(de.metas.ui.web.window.datatypes.DocumentIdsSelection) DetailId(de.metas.ui.web.window.descriptor.DetailId) DocumentId(de.metas.ui.web.window.datatypes.DocumentId)

Example 9 with DocumentId

use of de.metas.ui.web.window.datatypes.DocumentId in project metasfresh-webui-api by metasfresh.

the class SqlViewDataRepository method loadViewRow.

private ViewRow.Builder loadViewRow(final ResultSet rs, final WindowId windowId, final String adLanguage) throws SQLException {
    final boolean isRecordMissing = DisplayType.toBoolean(rs.getString(SqlViewSelectData.COLUMNNAME_IsRecordMissing));
    if (isRecordMissing) {
        return null;
    }
    final ViewRow.Builder viewRowBuilder = ViewRow.builder(windowId);
    final DocumentId parentRowId = keyColumnNamesMap.retrieveRowId(rs, SqlViewSelectData.COLUMNNAME_Paging_Parent_Prefix, false);
    if (parentRowId != null) {
        viewRowBuilder.setParentRowId(parentRowId);
        viewRowBuilder.setType(DefaultRowType.Line);
    } else {
        viewRowBuilder.setType(DefaultRowType.Row);
    }
    final DocumentId rowId = retrieveRowId(rs, adLanguage);
    if (rowId == null) {
        logger.warn("No ID found for current row. Skipping the row.");
        return null;
    }
    viewRowBuilder.setRowId(rowId);
    for (final Map.Entry<String, SqlViewRowFieldLoader> fieldNameAndLoader : rowFieldLoaders.entrySet()) {
        final String fieldName = fieldNameAndLoader.getKey();
        final SqlViewRowFieldLoader fieldLoader = fieldNameAndLoader.getValue();
        final Object value = fieldLoader.retrieveValueAsJson(rs, adLanguage);
        viewRowBuilder.putFieldValue(fieldName, value);
    }
    if (rowCustomizer != null) {
        rowCustomizer.customizeViewRow(viewRowBuilder);
    }
    return viewRowBuilder;
}
Also used : DocumentId(de.metas.ui.web.window.datatypes.DocumentId) SqlViewRowFieldLoader(de.metas.ui.web.view.descriptor.SqlViewRowFieldBinding.SqlViewRowFieldLoader) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) SqlViewKeyColumnNamesMap(de.metas.ui.web.view.descriptor.SqlViewKeyColumnNamesMap) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 10 with DocumentId

use of de.metas.ui.web.window.datatypes.DocumentId in project metasfresh-webui-api by metasfresh.

the class SqlViewRowIdsOrderedSelectionFactory method retrieveRowIdsForLineIds.

public static Set<DocumentId> retrieveRowIdsForLineIds(@NonNull SqlViewKeyColumnNamesMap keyColumnNamesMap, final ViewId viewId, final Set<Integer> lineIds) {
    final SqlAndParams sqlAndParams = SqlViewSelectionQueryBuilder.buildSqlSelectRowIdsForLineIds(keyColumnNamesMap, viewId.getViewId(), lineIds);
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try {
        pstmt = DB.prepareStatement(sqlAndParams.getSql(), ITrx.TRXNAME_ThreadInherited);
        DB.setParameters(pstmt, sqlAndParams.getSqlParams());
        rs = pstmt.executeQuery();
        final ImmutableSet.Builder<DocumentId> rowIds = ImmutableSet.builder();
        while (rs.next()) {
            final DocumentId rowId = keyColumnNamesMap.retrieveRowId(rs, "", false);
            rowIds.add(rowId);
        }
        return rowIds.build();
    } catch (final SQLException ex) {
        throw new DBException(ex, sqlAndParams.getSql(), sqlAndParams.getSqlParams());
    } finally {
        DB.close(rs, pstmt);
    }
}
Also used : DBException(org.adempiere.exceptions.DBException) ImmutableSet(com.google.common.collect.ImmutableSet) SQLException(java.sql.SQLException) SqlAndParams(de.metas.ui.web.view.descriptor.SqlAndParams) ResultSet(java.sql.ResultSet) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) PreparedStatement(java.sql.PreparedStatement)

Aggregations

DocumentId (de.metas.ui.web.window.datatypes.DocumentId)99 DocumentPath (de.metas.ui.web.window.datatypes.DocumentPath)18 DocumentIdsSelection (de.metas.ui.web.window.datatypes.DocumentIdsSelection)14 List (java.util.List)14 ImmutableList (com.google.common.collect.ImmutableList)12 GetMapping (org.springframework.web.bind.annotation.GetMapping)12 AdempiereException (org.adempiere.exceptions.AdempiereException)11 JSONLookupValuesList (de.metas.ui.web.window.datatypes.json.JSONLookupValuesList)9 ArrayList (java.util.ArrayList)9 Set (java.util.Set)9 NonNull (lombok.NonNull)9 Test (org.junit.Test)9 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)9 UserSession (de.metas.ui.web.session.UserSession)8 ViewId (de.metas.ui.web.view.ViewId)8 DocumentEntityDescriptor (de.metas.ui.web.window.descriptor.DocumentEntityDescriptor)8 Document (de.metas.ui.web.window.model.Document)8 IDocumentChangesCollector (de.metas.ui.web.window.model.IDocumentChangesCollector)8 TableRecordReference (org.adempiere.util.lang.impl.TableRecordReference)8 Autowired (org.springframework.beans.factory.annotation.Autowired)8