Search in sources :

Example 1 with UserId

use of de.metas.user.UserId in project metasfresh-webui-api by metasfresh.

the class NotificationRestController method getWebsocketEndpoint.

@GetMapping("/websocketEndpoint")
public final String getWebsocketEndpoint() {
    userSession.assertLoggedIn();
    final UserId adUserId = userSession.getLoggedUserId();
    return userNotificationsService.getWebsocketEndpoint(adUserId);
}
Also used : UserId(de.metas.user.UserId) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 2 with UserId

use of de.metas.user.UserId in project metasfresh-webui-api by metasfresh.

the class NotificationRestController method markAsRead.

@PutMapping("/{notificationId}/read")
public void markAsRead(@PathVariable("notificationId") final String notificationId) {
    userSession.assertLoggedIn();
    final UserId adUserId = userSession.getLoggedUserId();
    userNotificationsService.markNotificationAsRead(adUserId, notificationId);
}
Also used : UserId(de.metas.user.UserId) PutMapping(org.springframework.web.bind.annotation.PutMapping)

Example 3 with UserId

use of de.metas.user.UserId in project metasfresh-webui-api by metasfresh.

the class MenuTreeRepository method setFavorite.

public void setFavorite(final MenuNode menuNode, final boolean favorite) {
    final int adMenuId = menuNode.getAD_Menu_ID();
    final UserMenuFavorites userMenuFavorites = getUserMenuFavorites();
    final UserId adUserId = userMenuFavorites.getAdUserId();
    // Update in database first
    if (favorite) {
        Services.get(IUserMenuFavoritesDAO.class).add(adUserId, adMenuId);
    } else {
        Services.get(IUserMenuFavoritesDAO.class).remove(adUserId, adMenuId);
    }
    // Update model
    userMenuFavorites.setFavorite(adMenuId, favorite);
}
Also used : UserId(de.metas.user.UserId) IUserMenuFavoritesDAO(de.metas.user.api.IUserMenuFavoritesDAO)

Example 4 with UserId

use of de.metas.user.UserId in project metasfresh-webui-api by metasfresh.

the class UserNotificationsService method forwardEventToNotificationsQueues.

private void forwardEventToNotificationsQueues(final IEventBus eventBus, final Event event) {
    logger.trace("Got event from {}: {}", eventBus, event);
    final UserNotification notification = UserNotificationUtils.toUserNotification(event);
    final UserId recipientUserId = UserId.ofRepoId(notification.getRecipientUserId());
    final UserNotificationsQueue notificationsQueue = getNotificationsQueueOrNull(recipientUserId);
    if (notificationsQueue == null) {
        logger.trace("No notification queue was found for recipientUserId={}", recipientUserId);
        return;
    }
    notificationsQueue.addNotification(notification);
}
Also used : UserId(de.metas.user.UserId) UserNotification(de.metas.notification.UserNotification)

Example 5 with UserId

use of de.metas.user.UserId in project metasfresh-webui-api by metasfresh.

the class MailRestController method createNewEmail.

@PostMapping()
@ApiOperation("Creates a new email")
public JSONEmail createNewEmail(@RequestBody final JSONEmailRequest request) {
    userSession.assertLoggedIn();
    final UserId adUserId = userSession.getLoggedUserId();
    usersService.assertCanSendEMail(adUserId);
    final IntegerLookupValue from = IntegerLookupValue.of(adUserId.getRepoId(), userSession.getUserFullname() + " <" + userSession.getUserEmail() + "> ");
    final DocumentPath contextDocumentPath = JSONDocumentPath.toDocumentPathOrNull(request.getDocumentPath());
    final BoilerPlateContext attributes = documentCollection.createBoilerPlateContext(contextDocumentPath);
    final Integer toUserId = attributes.getAD_User_ID();
    final LookupValue to = mailRepo.getToByUserId(toUserId);
    final String emailId = mailRepo.createNewEmail(adUserId, from, to, contextDocumentPath).getEmailId();
    if (contextDocumentPath != null) {
        try {
            final DocumentPrint contextDocumentPrint = documentCollection.createDocumentPrint(contextDocumentPath);
            attachFile(emailId, () -> mailAttachmentsRepo.createAttachment(emailId, contextDocumentPrint.getFilename(), contextDocumentPrint.getReportData()));
        } catch (final Exception ex) {
            logger.debug("Failed creating attachment from document print of {}", contextDocumentPath, ex);
        }
    }
    return JSONEmail.of(mailRepo.getEmail(emailId), userSession.getAD_Language());
}
Also used : UserId(de.metas.user.UserId) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) JSONDocumentPath(de.metas.ui.web.window.datatypes.json.JSONDocumentPath) IntegerLookupValue(de.metas.ui.web.window.datatypes.LookupValue.IntegerLookupValue) BoilerPlateContext(de.metas.letters.model.MADBoilerPlate.BoilerPlateContext) DocumentPrint(de.metas.ui.web.window.model.DocumentCollection.DocumentPrint) FillMandatoryException(org.adempiere.exceptions.FillMandatoryException) IOException(java.io.IOException) AdempiereException(org.adempiere.exceptions.AdempiereException) IntegerLookupValue(de.metas.ui.web.window.datatypes.LookupValue.IntegerLookupValue) JSONLookupValue(de.metas.ui.web.window.datatypes.json.JSONLookupValue) LookupValue(de.metas.ui.web.window.datatypes.LookupValue) PostMapping(org.springframework.web.bind.annotation.PostMapping) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

UserId (de.metas.user.UserId)22 AdempiereException (org.adempiere.exceptions.AdempiereException)4 GetMapping (org.springframework.web.bind.annotation.GetMapping)4 BoilerPlateContext (de.metas.letters.model.MADBoilerPlate.BoilerPlateContext)3 DocumentPath (de.metas.ui.web.window.datatypes.DocumentPath)3 LookupValue (de.metas.ui.web.window.datatypes.LookupValue)3 JSONDocumentPath (de.metas.ui.web.window.datatypes.json.JSONDocumentPath)3 ApiOperation (io.swagger.annotations.ApiOperation)3 DeleteMapping (org.springframework.web.bind.annotation.DeleteMapping)3 PostMapping (org.springframework.web.bind.annotation.PostMapping)3 ImmutableSet (com.google.common.collect.ImmutableSet)2 BPartnerId (de.metas.bpartner.BPartnerId)2 Principal (de.metas.security.Principal)2 Access (de.metas.security.permissions.Access)2 I_AD_User (org.compiere.model.I_AD_User)2 Supplier (com.google.common.base.Supplier)1 ImmutableList (com.google.common.collect.ImmutableList)1 BPartnerLocationId (de.metas.bpartner.BPartnerLocationId)1 DataEntryFieldId (de.metas.dataentry.DataEntryFieldId)1 FieldType (de.metas.dataentry.FieldType)1