Example usage for com.liferay.portal.kernel.messaging Message Message

List of usage examples for com.liferay.portal.kernel.messaging Message Message

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.messaging Message Message.

Prototype

Message

Source Link

Usage

From source file:com.fingence.slayer.service.impl.PortfolioLocalServiceImpl.java

License:Open Source License

public void updatePortfolio(long portfolioId, long userId, String portfolioName, long investorId,
        long institutionId, long wealthAdvisorId, boolean trial, long relationshipManagerId, boolean social,
        String baseCurrency, File excelFile) {

    Portfolio portfolio = getPortfolioObj(portfolioId, userId);

    portfolioId = portfolio.getPortfolioId();
    portfolio.setPortfolioName(portfolioName);
    portfolio.setInvestorId(investorId);
    portfolio.setWealthAdvisorId(wealthAdvisorId);
    portfolio.setRelationshipManagerId(relationshipManagerId);
    portfolio.setInstitutionId(institutionId);
    portfolio.setTrial(trial);//from w ww .  ja v  a2 s .c o  m
    portfolio.setPrimary(isFirstPortfolio(investorId));
    portfolio.setSocial(social);
    portfolio.setBaseCurrency(baseCurrency);

    try {
        portfolio = updatePortfolio(portfolio);
    } catch (SystemException e) {
        e.printStackTrace();
    }

    if (Validator.isNull(excelFile))
        return;

    InputStream is = null;
    try {
        is = new FileInputStream(excelFile);
    } catch (FileNotFoundException e) {
        //e.printStackTrace();
    }

    if (Validator.isNull(is))
        return;

    //Create Workbook instance holding reference to .xlsx file
    XSSFWorkbook workbook = null;
    try {
        workbook = new XSSFWorkbook(is);
    } catch (IOException e) {
        e.printStackTrace();
    }

    //Get first/desired sheet from the workbook
    XSSFSheet sheet = workbook.getSheetAt(0);

    //Iterate through each rows one by one
    Iterator<Row> rowIterator = sheet.iterator();

    while (rowIterator.hasNext()) {
        // get the individual columns. 

        Row row = rowIterator.next();
        if (row.getRowNum() == 0)
            continue;

        String id_isin = CellUtil.getString(row.getCell(0));

        Asset asset = null;
        try {
            asset = assetPersistence.fetchByIdISIN(id_isin);
        } catch (SystemException e) {
            e.printStackTrace();
        }

        if (Validator.isNull(asset))
            continue;

        long assetId = asset.getAssetId();

        PortfolioItem portfolioItem = null;
        try {
            portfolioItem = portfolioItemPersistence.fetchByAssetId_PortfolioId(assetId, portfolioId);
        } catch (SystemException e) {
            e.printStackTrace();
        }

        if (Validator.isNull(portfolioItem)) {
            long itemId = 0l;
            try {
                itemId = counterLocalService.increment(PortfolioItem.class.getName());
            } catch (SystemException e) {
                e.printStackTrace();
            }
            portfolioItem = portfolioItemLocalService.createPortfolioItem(itemId);
            portfolioItem.setCreateDate(new java.util.Date());
            portfolioItem.setPortfolioId(portfolioId);
            portfolioItem.setAssetId(assetId);

            try {
                portfolioItemLocalService.addPortfolioItem(portfolioItem);
            } catch (SystemException e) {
                e.printStackTrace();
            }
        } else {
            portfolioItem.setModifiedDate(new java.util.Date());
        }

        portfolioItem.setPurchaseDate(CellUtil.getDate(row.getCell(2)));
        portfolioItem.setPurchasePrice(CellUtil.getDouble(row.getCell(3)));
        portfolioItem.setPurchaseQty(CellUtil.getDouble(row.getCell(4)));

        double purchasedFx = asset.getCurrency().equalsIgnoreCase(IConstants.CURRENCY_USD) ? 1.0d
                : CellUtil.getDouble(row.getCell(5));

        if (purchasedFx == 0.0d) {
            purchasedFx = ConversionUtil.getConversion(asset.getCurrency(), portfolioItem.getPurchaseDate());
        }

        portfolioItem.setPurchasedFx(purchasedFx);

        try {
            portfolioItemLocalService.updatePortfolioItem(portfolioItem);
        } catch (SystemException e) {
            e.printStackTrace();
        }
    }

    if (Validator.isNotNull(excelFile)) {
        // invoke JMS
        Message message = new Message();
        message.put("MESSAGE_NAME", "setConvertionRate");
        message.put("portfolioId", portfolioId);

        // Temporarily commenting this out
        //MessageBusUtil.sendMessage("fingence/destination", message);           
    }
}

From source file:com.inikah.slayer.service.impl.PhotoLocalServiceImpl.java

License:Open Source License

public Photo upload(long imageId, long profileId, File file, String description) {

    Photo photo = null;/*ww  w . j  a v  a2 s  .  co m*/

    if (imageId == 0l) {
        try {
            imageId = counterLocalService.increment(Image.class.getName());
            photo = createPhoto(imageId);
            photo = addPhoto(photo);
        } catch (SystemException e) {
            e.printStackTrace();
        }
    } else {
        try {
            photo = fetchPhoto(imageId);
        } catch (SystemException e) {
            e.printStackTrace();
        }
    }

    try {
        Image image = imageLocalService.updateImage(imageId, file);
        photo.setContentType(image.getType());
    } catch (PortalException e) {
        e.printStackTrace();
    } catch (SystemException e) {
        e.printStackTrace();
    }

    photo.setUploadDate(new java.util.Date());
    photo.setClassName(Profile.class.getName());
    photo.setClassPK(profileId);
    photo.setDescription(description);
    photo.setImageType(IConstants.IMG_TYPE_PHOTO);

    try {
        photo = updatePhoto(photo);
    } catch (SystemException e) {
        e.printStackTrace();
    }

    //createThumbnail(imageId);
    Message message = new Message();
    message.put("messageName", "createThumbnail");
    message.put("imageId", String.valueOf(imageId));
    MessageBusUtil.sendMessage("inikah/destination", message);

    return photo;
}

From source file:com.inkwell.internet.slogan.service.impl.SloganLocalServiceImpl.java

License:Open Source License

private void sendMessage(Slogan slogan, ServiceContext serviceContext) {

    Message message = new Message();
    message.put("userId", serviceContext.getUserId());
    message.put("slogan", slogan.getSloganText());
    MessageBusUtil.sendMessage("inkwell/slogan", message);
}

From source file:com.library.slayer.service.impl.LMSBookLocalServiceImpl.java

License:Open Source License

public void sendMessage(LMSBook lmsBook, ServiceContext serviceContext) {
    /*/*from  w  w w .  jav  a2  s  .  co  m*/
     * Here we are setting the message that Message Bus will carry to the
     * Listener class. Here we are setting the id and name of the book that
     * the user has added into the databse
     */
    Message message = new Message();
    message.put("bookID", lmsBook.getBookId());
    message.put("bookName", lmsBook.getBookTitle());
    /*
     * Now we are sending the message to the listener class
     */
    MessageBusUtil.sendMessage("destinationBus", message);
}

From source file:com.liferay.adaptive.media.blogs.web.internal.optimizer.BlogsAdaptiveMediaImageOptimizer.java

License:Open Source License

private void _sendStatusMessage(int count, int total) {
    Message message = new Message();

    message.put(BackgroundTaskConstants.BACKGROUND_TASK_ID, BackgroundTaskThreadLocal.getBackgroundTaskId());

    Class<? extends BlogsAdaptiveMediaImageOptimizer> clazz = getClass();

    message.put(OptimizeImagesBackgroundTaskConstants.CLASS_NAME, clazz.getName());

    message.put(OptimizeImagesBackgroundTaskConstants.COUNT, count);
    message.put(OptimizeImagesBackgroundTaskConstants.TOTAL, total);

    message.put("status", BackgroundTaskConstants.STATUS_IN_PROGRESS);

    _backgroundTaskStatusMessageSender.sendBackgroundTaskStatusMessage(message);
}

From source file:com.liferay.adaptive.media.blogs.web.internal.optimizer.BlogsAMImageOptimizer.java

License:Open Source License

private void _sendStatusMessage(int count, int total) {
    Message message = new Message();

    message.put(BackgroundTaskConstants.BACKGROUND_TASK_ID, BackgroundTaskThreadLocal.getBackgroundTaskId());

    Class<? extends BlogsAMImageOptimizer> clazz = getClass();

    message.put(AMOptimizeImagesBackgroundTaskConstants.CLASS_NAME, clazz.getName());

    message.put(AMOptimizeImagesBackgroundTaskConstants.COUNT, count);
    message.put(AMOptimizeImagesBackgroundTaskConstants.TOTAL, total);

    message.put("status", BackgroundTaskConstants.STATUS_IN_PROGRESS);

    _backgroundTaskStatusMessageSender.sendBackgroundTaskStatusMessage(message);
}

From source file:com.liferay.adaptive.media.document.library.repository.internal.optimizer.DLAdaptiveMediaImageOptimizer.java

License:Open Source License

private void _sendStatusMessage(int count, int total) {
    Message message = new Message();

    message.put(BackgroundTaskConstants.BACKGROUND_TASK_ID, BackgroundTaskThreadLocal.getBackgroundTaskId());

    Class<? extends DLAdaptiveMediaImageOptimizer> clazz = getClass();

    message.put(OptimizeImagesBackgroundTaskConstants.CLASS_NAME, clazz.getName());

    message.put(OptimizeImagesBackgroundTaskConstants.COUNT, count);
    message.put(OptimizeImagesBackgroundTaskConstants.TOTAL, total);

    message.put("status", BackgroundTaskConstants.STATUS_IN_PROGRESS);

    _backgroundTaskStatusMessageSender.sendBackgroundTaskStatusMessage(message);
}

From source file:com.liferay.adaptive.media.document.library.web.internal.optimizer.DLAMImageOptimizer.java

License:Open Source License

private void _sendStatusMessage(int count, int total) {
    Message message = new Message();

    message.put(BackgroundTaskConstants.BACKGROUND_TASK_ID, BackgroundTaskThreadLocal.getBackgroundTaskId());

    Class<? extends DLAMImageOptimizer> clazz = getClass();

    message.put(AMOptimizeImagesBackgroundTaskConstants.CLASS_NAME, clazz.getName());

    message.put(AMOptimizeImagesBackgroundTaskConstants.COUNT, count);
    message.put(AMOptimizeImagesBackgroundTaskConstants.TOTAL, total);

    message.put("status", BackgroundTaskConstants.STATUS_IN_PROGRESS);

    _backgroundTaskStatusMessageSender.sendBackgroundTaskStatusMessage(message);
}

From source file:com.liferay.adaptive.media.image.internal.configuration.AdaptiveMediaImageConfigurationHelperImpl.java

License:Open Source License

private void _triggerConfigurationEvent(Object payload) {
    Message message = new Message();

    message.setPayload(payload);/*from   ww  w .  ja  v a  2 s  . co  m*/

    _messageBus.sendMessage(AdaptiveMediaImageDestinationNames.ADAPTIVE_MEDIA_IMAGE_CONFIGURATION, message);
}

From source file:com.liferay.adaptive.media.image.internal.configuration.AMImageConfigurationHelperImpl.java

License:Open Source License

private void _triggerConfigurationEvent(Object payload) {
    Message message = new Message();

    message.setPayload(payload);/*from  w w  w  .  j  a va 2  s .com*/

    _messageBus.sendMessage(AMImageDestinationNames.ADAPTIVE_MEDIA_IMAGE_CONFIGURATION, message);
}