Search in sources :

Example 1 with ClientId

use of org.adempiere.service.ClientId in project metasfresh-webui-api by metasfresh.

the class UserDashboardRepository method retrieveUserDashboardId.

private int retrieveUserDashboardId(final UserDashboardKey key) {
    final ClientId adClientId = key.getAdClientId();
    final int dashboardId = queryBL.createQueryBuilder(I_WEBUI_Dashboard.class).addOnlyActiveRecordsFilter().addInArrayFilter(I_WEBUI_Dashboard.COLUMN_AD_Client_ID, ClientId.SYSTEM, adClientId).orderBy().addColumn(I_WEBUI_Dashboard.COLUMN_AD_Client_ID, Direction.Descending, Nulls.Last).addColumn(I_WEBUI_Dashboard.COLUMN_IsDefault, Direction.Descending, Nulls.Last).addColumn(I_WEBUI_Dashboard.COLUMN_WEBUI_Dashboard_ID).endOrderBy().create().firstId();
    return dashboardId > 0 ? dashboardId : -1;
}
Also used : I_WEBUI_Dashboard(de.metas.ui.web.base.model.I_WEBUI_Dashboard) ClientId(org.adempiere.service.ClientId)

Example 2 with ClientId

use of org.adempiere.service.ClientId in project metasfresh-webui-api by metasfresh.

the class WEBUI_Fact_Acct_Repost_ViewRows method extractDocumentToRepostFromTableAndRecordIdRow.

private DocumentToRepost extractDocumentToRepostFromTableAndRecordIdRow(final IViewRow row) {
    final int adTableId = row.getFieldValueAsInt(I_Fact_Acct.COLUMNNAME_AD_Table_ID, -1);
    final int recordId = row.getFieldValueAsInt(I_Fact_Acct.COLUMNNAME_Record_ID, -1);
    final ClientId adClientId = ClientId.ofRepoId(row.getFieldValueAsInt(I_Fact_Acct.COLUMNNAME_AD_Client_ID, -1));
    return DocumentToRepost.builder().adTableId(adTableId).recordId(recordId).clientId(adClientId).build();
}
Also used : ClientId(org.adempiere.service.ClientId)

Example 3 with ClientId

use of org.adempiere.service.ClientId in project metasfresh-webui-api by metasfresh.

the class WEBUI_Fact_Acct_Repost_ViewRows method extractDocumentToRepostFromRegularRow.

private DocumentToRepost extractDocumentToRepostFromRegularRow(final IViewRow row) {
    final int adTableId = adTablesRepo.retrieveTableId(getTableName());
    final int recordId = row.getId().toInt();
    final ClientId adClientId = ClientId.ofRepoId(row.getFieldValueAsInt(I_Fact_Acct.COLUMNNAME_AD_Client_ID, -1));
    return DocumentToRepost.builder().adTableId(adTableId).recordId(recordId).clientId(adClientId).build();
}
Also used : ClientId(org.adempiere.service.ClientId)

Example 4 with ClientId

use of org.adempiere.service.ClientId in project metasfresh-webui-api by metasfresh.

the class SqlDocumentsRepository method retrieveNextDocumentId.

private static DocumentId retrieveNextDocumentId(final DocumentEntityDescriptor entityDescriptor) {
    final SqlDocumentEntityDataBindingDescriptor dataBinding = SqlDocumentEntityDataBindingDescriptor.cast(entityDescriptor.getDataBinding());
    final ClientId adClientId = UserSession.getCurrent().getClientId();
    final String tableName = dataBinding.getTableName();
    final int nextId = DB.getNextID(adClientId.getRepoId(), tableName, ITrx.TRXNAME_ThreadInherited);
    if (nextId <= 0) {
        throw new DBException("Cannot retrieve next ID from database for " + entityDescriptor);
    }
    logger.trace("Acquired next ID={} for {}", nextId, entityDescriptor);
    return DocumentId.of(nextId);
}
Also used : DBException(org.adempiere.exceptions.DBException) SqlDocumentEntityDataBindingDescriptor(de.metas.ui.web.window.descriptor.sql.SqlDocumentEntityDataBindingDescriptor) ClientId(org.adempiere.service.ClientId)

Example 5 with ClientId

use of org.adempiere.service.ClientId in project metasfresh-webui-api by metasfresh.

the class WEBUI_Fact_Acct_Repost_SingleDocument method extractDocumentToRepostFromSingleDocumentOrNull.

private DocumentToRepost extractDocumentToRepostFromSingleDocumentOrNull(final Document document) {
    final BooleanWithReason allowReposting = checkAllowReposting(document);
    if (allowReposting.isFalse()) {
        throw new AdempiereException(allowReposting.getReason());
    }
    final String tableName = document.getEntityDescriptor().getTableName();
    final int adTableId = adTablesRepo.retrieveTableId(tableName);
    final int recordId = document.getDocumentIdAsInt();
    final ClientId adClientId = document.getClientId();
    return DocumentToRepost.builder().adTableId(adTableId).recordId(recordId).clientId(adClientId).build();
}
Also used : BooleanWithReason(de.metas.i18n.BooleanWithReason) AdempiereException(org.adempiere.exceptions.AdempiereException) ClientId(org.adempiere.service.ClientId)

Aggregations

ClientId (org.adempiere.service.ClientId)8 OrgId (de.metas.organization.OrgId)2 AdempiereException (org.adempiere.exceptions.AdempiereException)2 DBException (org.adempiere.exceptions.DBException)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 BooleanWithReason (de.metas.i18n.BooleanWithReason)1 RoleId (de.metas.security.RoleId)1 I_WEBUI_Dashboard (de.metas.ui.web.base.model.I_WEBUI_Dashboard)1 JSONLoginRole (de.metas.ui.web.login.json.JSONLoginRole)1 DocumentPath (de.metas.ui.web.window.datatypes.DocumentPath)1 SqlDocumentEntityDataBindingDescriptor (de.metas.ui.web.window.descriptor.sql.SqlDocumentEntityDataBindingDescriptor)1 UserId (de.metas.user.UserId)1 HashableString (de.metas.util.hash.HashableString)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 AdWindowId (org.adempiere.ad.element.api.AdWindowId)1 KeyNamePair (org.compiere.util.KeyNamePair)1 LoginContext (org.compiere.util.LoginContext)1