Example usage for com.liferay.portal.kernel.workflow WorkflowConstants LABEL_DENIED

List of usage examples for com.liferay.portal.kernel.workflow WorkflowConstants LABEL_DENIED

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.workflow WorkflowConstants LABEL_DENIED.

Prototype

String LABEL_DENIED

To view the source code for com.liferay.portal.kernel.workflow WorkflowConstants LABEL_DENIED.

Click Source Link

Usage

From source file:com.mpower.services.service.impl.BookLocalServiceImpl.java

License:Open Source License

public Book updateStatus(long userId, long resourcePrimKey, int status, ServiceContext serviceContext) {

    Book book = null;/*from  w w  w .ja  v  a2s .  c  o  m*/
    System.out.println("BookLocalServiceImpl:updateStatus");
    try {
        User user = userPersistence.findByPrimaryKey(userId);
        book = bookPersistence.findByPrimaryKey(resourcePrimKey);
        String labelStatus = "";

        if (book != null) {
            if (status == 2) {
                labelStatus = WorkflowConstants.LABEL_DRAFT;
                labelStatus = labelStatus.substring(0, 1).toUpperCase() + labelStatus.substring(1);
            } else if (status == 1) {
                labelStatus = WorkflowConstants.LABEL_PENDING;
                labelStatus = labelStatus.substring(0, 1).toUpperCase() + labelStatus.substring(1);
            } else if (status == 0) {
                labelStatus = WorkflowConstants.LABEL_APPROVED;
                labelStatus = labelStatus.substring(0, 1).toUpperCase() + labelStatus.substring(1);
            } else {
                labelStatus = WorkflowConstants.LABEL_DENIED;
                labelStatus = labelStatus.substring(0, 1).toUpperCase() + labelStatus.substring(1);
            }

            if (book != null) {
                book.setStatus(labelStatus);
                bookPersistence.update(book, true);

                //update extworkflowtable
                /*ExtWorkFlow extWorkFlow = ExtWorkFlowLocalServiceUtil.getExtWorkFlow(book.getBookId());
                extWorkFlow.setStatus(status);
                ExtWorkFlowLocalServiceUtil.updateExtWorkFlow(extWorkFlow, true);*/

            }

            if (labelStatus.equalsIgnoreCase(WorkflowConstants.LABEL_APPROVED)) {
                return book;
            }

        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return book;

}