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

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

Introduction

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

Prototype

int STATUS_APPROVED

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

Click Source Link

Usage

From source file:com.liferay.calendarimporter.source.LotusNotesImportSource.java

License:Open Source License

protected void importEvent(Calendar calendar, JSONObject eventJSON) throws Exception {

    User user = UserLocalServiceUtil.getUser(calendar.getUserId());
    Locale locale = user.getLocale();

    String uuid = eventJSON.getString("id");
    Map<Locale, String> titleMap = getLocalizedMap(eventJSON, locale, "summary");
    Map<Locale, String> descriptionMap = getLocalizedMap(eventJSON, locale, "description");
    String location = eventJSON.getString("location");
    long startTime = getTime(eventJSON, "start");
    long endTime = getTime(eventJSON, "end");
    boolean allDay = false;
    String recurrence = null;/*from  ww  w. j  a  va 2 s  .c  om*/
    long firstReminder = 0;
    String firstReminderType = null;
    long secondReminder = 0;
    String secondReminderType = null;

    ServiceContext serviceContext = new ServiceContext();

    serviceContext.setUuid(uuid);

    CalendarBooking calendarBooking = CalendarBookingLocalServiceUtil.fetchCalendarBooking(uuid,
            calendar.getGroupId());

    if (calendarBooking != null) {
        CalendarBookingLocalServiceUtil.updateCalendarBooking(user.getUserId(),
                calendarBooking.getCalendarBookingId(), calendarBooking.getCalendarId(), titleMap,
                descriptionMap, location, startTime, endTime, allDay, recurrence, firstReminder,
                firstReminderType, secondReminder, secondReminderType, WorkflowConstants.STATUS_APPROVED,
                serviceContext);
    } else {
        CalendarBookingLocalServiceUtil.addCalendarBooking(user.getUserId(), calendar.getCalendarId(),
                new long[0], CalendarBookingConstants.PARENT_CALENDAR_BOOKING_ID_DEFAULT, titleMap,
                descriptionMap, location, startTime, endTime, allDay, recurrence, firstReminder,
                firstReminderType, secondReminder, secondReminderType, serviceContext);
    }
}

From source file:com.liferay.comment.notifications.test.CommentUserNotificationTest.java

License:Open Source License

@Override
protected BaseModel<?> addBaseModel() throws Exception {
    MBMessageDisplay messageDisplay = MBMessageLocalServiceUtil.getDiscussionMessageDisplay(
            TestPropsValues.getUserId(), group.getGroupId(), BlogsEntry.class.getName(), _entry.getEntryId(),
            WorkflowConstants.STATUS_APPROVED);

    MBThread thread = messageDisplay.getThread();

    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(group.getGroupId(),
            TestPropsValues.getUserId());

    MBTestUtil.populateNotificationsServiceContext(serviceContext, Constants.ADD);

    return MBMessageLocalServiceUtil.addDiscussionMessage(TestPropsValues.getUserId(),
            RandomTestUtil.randomString(), group.getGroupId(), BlogsEntry.class.getName(), _entry.getEntryId(),
            thread.getThreadId(), MBMessageConstants.DEFAULT_PARENT_MESSAGE_ID, RandomTestUtil.randomString(),
            RandomTestUtil.randomString(50), serviceContext);
}

From source file:com.liferay.comment.subscriptions.test.CommentsSubscriptionTest.java

License:Open Source License

protected MBMessage addDiscussionMessage(long userId, ServiceContext serviceContext, BlogsEntry entry)
        throws Exception {

    MBMessageDisplay messageDisplay = MBMessageLocalServiceUtil.getDiscussionMessageDisplay(
            TestPropsValues.getUserId(), _group.getGroupId(), BlogsEntry.class.getName(), entry.getEntryId(),
            WorkflowConstants.STATUS_APPROVED);

    MBThread thread = messageDisplay.getThread();

    MBTestUtil.populateNotificationsServiceContext(serviceContext, Constants.ADD);

    return MBMessageLocalServiceUtil.addDiscussionMessage(userId, RandomTestUtil.randomString(),
            _group.getGroupId(), BlogsEntry.class.getName(), entry.getEntryId(), thread.getThreadId(),
            MBMessageConstants.DEFAULT_PARENT_MESSAGE_ID, RandomTestUtil.randomString(),
            RandomTestUtil.randomString(), serviceContext);
}

From source file:com.liferay.contacts.contactscenter.portlet.ContactsCenterPortlet.java

License:Open Source License

protected JSONObject getContactsJSONObject(PortletRequest portletRequest, PortletResponse portletResponse)
        throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    String redirect = ParamUtil.getString(portletRequest, "redirect");

    String filterBy = ParamUtil.getString(portletRequest, "filterBy");
    String keywords = ParamUtil.getString(portletRequest, "keywords");
    int start = ParamUtil.getInteger(portletRequest, "start");
    int end = ParamUtil.getInteger(portletRequest, "end");

    JSONObject jsonObject = JSONFactoryUtil.createJSONObject();

    JSONObject optionsJSONObject = JSONFactoryUtil.createJSONObject();

    optionsJSONObject.put("end", end);
    optionsJSONObject.put("filterBy", filterBy);
    optionsJSONObject.put("keywords", keywords);
    optionsJSONObject.put("start", start);

    jsonObject.put("options", optionsJSONObject);

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    String portletId = portletDisplay.getId();

    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();

    if (filterBy.equals(ContactsConstants.FILTER_BY_DEFAULT) && !portletId.equals(PortletKeys.MEMBERS)) {

        List<BaseModel<?>> contacts = EntryLocalServiceUtil.searchUsersAndContacts(themeDisplay.getCompanyId(),
                themeDisplay.getUserId(), keywords, start, end);

        int contactsCount = EntryLocalServiceUtil.searchUsersAndContactsCount(themeDisplay.getCompanyId(),
                themeDisplay.getUserId(), keywords);

        jsonObject.put("count", contactsCount);

        for (BaseModel<?> contact : contacts) {
            JSONObject contactJSONObject = null;

            if (contact instanceof User) {
                contactJSONObject = getUserJSONObject(portletResponse, themeDisplay, (User) contact);
            } else {
                contactJSONObject = getEntryJSONObject(portletResponse, themeDisplay, (Entry) contact,
                        redirect);/*w  w  w . ja  va 2s.c o  m*/
            }

            jsonArray.put(contactJSONObject);
        }
    } else if (filterBy.equals(ContactsConstants.FILTER_BY_FOLLOWERS)
            && !portletId.equals(PortletKeys.MEMBERS)) {

        List<SocialRelation> socialRelations = SocialRelationLocalServiceUtil.getInverseRelations(
                themeDisplay.getUserId(), SocialRelationConstants.TYPE_UNI_FOLLOWER, start, end);

        for (SocialRelation socialRelation : socialRelations) {
            jsonArray.put(getUserJSONObject(portletResponse, themeDisplay, socialRelation.getUserId1()));
        }
    } else if (filterBy.equals(ContactsConstants.FILTER_BY_TYPE_MY_CONTACTS)
            && !portletId.equals(PortletKeys.MEMBERS)) {

        List<Entry> entries = EntryLocalServiceUtil.search(themeDisplay.getUserId(), keywords, start, end);

        int entriesCount = EntryLocalServiceUtil.searchCount(themeDisplay.getUserId(), keywords);

        jsonObject.put("count", entriesCount);

        for (Entry entry : entries) {
            JSONObject contactJSONObject = getEntryJSONObject(portletResponse, themeDisplay, entry, redirect);

            jsonArray.put(contactJSONObject);
        }
    } else {
        LinkedHashMap<String, Object> params = new LinkedHashMap<String, Object>();

        params.put("inherit", Boolean.TRUE);

        Group group = themeDisplay.getScopeGroup();
        Layout layout = themeDisplay.getLayout();

        if (group.isUser() && layout.isPublicLayout()) {
            params.put("socialRelationType",
                    new Long[] { group.getClassPK(), (long) SocialRelationConstants.TYPE_BI_CONNECTION });
        } else if (filterBy.startsWith(ContactsConstants.FILTER_BY_TYPE)) {
            params.put("socialRelationType",
                    new Long[] { themeDisplay.getUserId(), ContactsUtil.getSocialRelationType(filterBy) });
        }

        if (portletId.equals(PortletKeys.MEMBERS)) {
            params.put("usersGroups", group.getGroupId());
        } else if (filterBy.startsWith(ContactsConstants.FILTER_BY_GROUP)) {
            params.put("usersGroups", ContactsUtil.getGroupId(filterBy));
        }

        List<User> usersList = null;

        if (filterBy.equals(ContactsConstants.FILTER_BY_ADMINS)) {
            Role siteAdministratorRole = RoleLocalServiceUtil.getRole(group.getCompanyId(),
                    RoleConstants.SITE_ADMINISTRATOR);

            params.put("userGroupRole",
                    new Long[] { new Long(group.getGroupId()), new Long(siteAdministratorRole.getRoleId()) });

            Set<User> users = new HashSet<User>();

            users.addAll(UserLocalServiceUtil.search(themeDisplay.getCompanyId(), keywords,
                    WorkflowConstants.STATUS_APPROVED, params, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
                    (OrderByComparator) null));

            Role siteOwnerRole = RoleLocalServiceUtil.getRole(group.getCompanyId(), RoleConstants.SITE_OWNER);

            params.put("userGroupRole",
                    new Long[] { new Long(group.getGroupId()), new Long(siteOwnerRole.getRoleId()) });

            users.addAll(UserLocalServiceUtil.search(themeDisplay.getCompanyId(), keywords,
                    WorkflowConstants.STATUS_APPROVED, params, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
                    (OrderByComparator) null));

            usersList = new ArrayList<User>(users);

            ListUtil.sort(usersList, new UserLastNameComparator(true));
        } else {
            int usersCount = UserLocalServiceUtil.searchCount(themeDisplay.getCompanyId(), keywords,
                    WorkflowConstants.STATUS_APPROVED, params);

            jsonObject.put("count", usersCount);

            usersList = UserLocalServiceUtil.search(themeDisplay.getCompanyId(), keywords,
                    WorkflowConstants.STATUS_APPROVED, params, start, end, new UserLastNameComparator(true));
        }

        for (User user : usersList) {
            JSONObject userJSONObject = getUserJSONObject(portletResponse, themeDisplay, user);

            jsonArray.put(userJSONObject);
        }
    }

    jsonObject.put("users", jsonArray);

    return jsonObject;
}

From source file:com.liferay.contacts.web.internal.portlet.ContactsCenterPortlet.java

License:Open Source License

protected JSONObject getContactsJSONObject(PortletRequest portletRequest, PortletResponse portletResponse)
        throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    String redirect = ParamUtil.getString(portletRequest, "redirect");

    String filterBy = ParamUtil.getString(portletRequest, "filterBy");
    String keywords = ParamUtil.getString(portletRequest, "keywords");
    int start = ParamUtil.getInteger(portletRequest, "start");
    int end = ParamUtil.getInteger(portletRequest, "end");

    JSONObject jsonObject = JSONFactoryUtil.createJSONObject();

    JSONObject optionsJSONObject = JSONFactoryUtil.createJSONObject();

    optionsJSONObject.put("end", end);
    optionsJSONObject.put("filterBy", filterBy);
    optionsJSONObject.put("keywords", keywords);
    optionsJSONObject.put("start", start);

    jsonObject.put("options", optionsJSONObject);

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    String portletId = portletDisplay.getId();

    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();

    if (filterBy.equals(ContactsConstants.FILTER_BY_DEFAULT)
            && !portletId.equals(ContactsPortletKeys.MEMBERS)) {

        List<BaseModel<?>> contacts = entryLocalService.searchUsersAndContacts(themeDisplay.getCompanyId(),
                themeDisplay.getUserId(), keywords, start, end);

        int contactsCount = entryLocalService.searchUsersAndContactsCount(themeDisplay.getCompanyId(),
                themeDisplay.getUserId(), keywords);

        jsonObject.put("count", contactsCount);

        for (BaseModel<?> contact : contacts) {
            JSONObject contactJSONObject = null;

            if (contact instanceof User) {
                contactJSONObject = getUserJSONObject(portletResponse, themeDisplay, (User) contact);
            } else {
                contactJSONObject = getEntryJSONObject(portletResponse, themeDisplay, (Entry) contact,
                        redirect);/*from w ww . j av  a 2 s  .  c  o  m*/
            }

            jsonArray.put(contactJSONObject);
        }
    } else if (filterBy.equals(ContactsConstants.FILTER_BY_FOLLOWERS)
            && !portletId.equals(ContactsPortletKeys.MEMBERS)) {

        List<SocialRelation> socialRelations = socialRelationLocalService.getInverseRelations(
                themeDisplay.getUserId(), SocialRelationConstants.TYPE_UNI_FOLLOWER, start, end);

        for (SocialRelation socialRelation : socialRelations) {
            jsonArray.put(getUserJSONObject(portletResponse, themeDisplay, socialRelation.getUserId1()));
        }
    } else if (filterBy.equals(ContactsConstants.FILTER_BY_TYPE_MY_CONTACTS)
            && !portletId.equals(ContactsPortletKeys.MEMBERS)) {

        List<Entry> entries = entryLocalService.search(themeDisplay.getUserId(), keywords, start, end);

        int entriesCount = entryLocalService.searchCount(themeDisplay.getUserId(), keywords);

        jsonObject.put("count", entriesCount);

        for (Entry entry : entries) {
            JSONObject contactJSONObject = getEntryJSONObject(portletResponse, themeDisplay, entry, redirect);

            jsonArray.put(contactJSONObject);
        }
    } else {
        LinkedHashMap<String, Object> params = new LinkedHashMap<>();

        params.put("inherit", Boolean.TRUE);

        Group group = themeDisplay.getScopeGroup();
        Layout layout = themeDisplay.getLayout();

        if (group.isUser() && layout.isPublicLayout()) {
            params.put("socialRelationType",
                    new Long[] { group.getClassPK(), (long) SocialRelationConstants.TYPE_BI_CONNECTION });
        } else if (filterBy.startsWith(ContactsConstants.FILTER_BY_TYPE)) {
            params.put("socialRelationType",
                    new Long[] { themeDisplay.getUserId(), ContactsUtil.getSocialRelationType(filterBy) });
        }

        if (portletId.equals(ContactsPortletKeys.MEMBERS)) {
            params.put("usersGroups", group.getGroupId());
        } else if (filterBy.startsWith(ContactsConstants.FILTER_BY_GROUP)) {
            params.put("usersGroups", ContactsUtil.getGroupId(filterBy));
        }

        List<User> usersList = null;

        if (filterBy.equals(ContactsConstants.FILTER_BY_ADMINS)) {
            Role siteAdministratorRole = roleLocalService.getRole(group.getCompanyId(),
                    RoleConstants.SITE_ADMINISTRATOR);

            params.put("userGroupRole", new Long[] { group.getGroupId(), siteAdministratorRole.getRoleId() });

            Set<User> users = new HashSet<>();

            users.addAll(userLocalService.search(themeDisplay.getCompanyId(), keywords,
                    WorkflowConstants.STATUS_APPROVED, params, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
                    (OrderByComparator) null));

            Role siteOwnerRole = roleLocalService.getRole(group.getCompanyId(), RoleConstants.SITE_OWNER);

            params.put("userGroupRole", new Long[] { group.getGroupId(), siteOwnerRole.getRoleId() });

            users.addAll(userLocalService.search(themeDisplay.getCompanyId(), keywords,
                    WorkflowConstants.STATUS_APPROVED, params, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
                    (OrderByComparator) null));

            usersList = new ArrayList<>(users);

            ListUtil.sort(usersList, new UserLastNameComparator(true));
        } else {
            int usersCount = userLocalService.searchCount(themeDisplay.getCompanyId(), keywords,
                    WorkflowConstants.STATUS_APPROVED, params);

            jsonObject.put("count", usersCount);

            usersList = userLocalService.search(themeDisplay.getCompanyId(), keywords,
                    WorkflowConstants.STATUS_APPROVED, params, start, end, new UserLastNameComparator(true));
        }

        for (User user : usersList) {
            JSONObject userJSONObject = getUserJSONObject(portletResponse, themeDisplay, user);

            jsonArray.put(userJSONObject);
        }
    }

    jsonObject.put("users", jsonArray);

    return jsonObject;
}

From source file:com.liferay.document.library.internal.repository.capabilities.MinimalWorkflowCapability.java

License:Open Source License

protected void doUpdateStatus(long userId, FileEntry fileEntry, ServiceContext serviceContext)
        throws PortalException {

    Map<String, Serializable> workflowContext = Collections.emptyMap();

    FileVersion fileVersion = fileEntry.getFileVersion();

    _dlFileEntryServiceAdapter.updateStatus(userId, fileVersion.getFileVersionId(),
            WorkflowConstants.STATUS_APPROVED, serviceContext, workflowContext);
}

From source file:com.liferay.document.library.internal.service.SubscriptionDLAppHelperLocalServiceWrapper.java

License:Open Source License

@Override
public void updateStatus(long userId, FileEntry fileEntry, FileVersion latestFileVersion, int oldStatus,
        int newStatus, ServiceContext serviceContext, Map<String, Serializable> workflowContext)
        throws PortalException {

    if (!_isEnabled(fileEntry)) {
        return;/*from   w ww .jav  a  2 s  .co  m*/
    }

    super.updateStatus(userId, fileEntry, latestFileVersion, oldStatus, newStatus, serviceContext,
            workflowContext);

    if ((newStatus == WorkflowConstants.STATUS_APPROVED) && (oldStatus != WorkflowConstants.STATUS_IN_TRASH)
            && !fileEntry.isInTrash()) {

        // Subscriptions

        notifySubscribers(userId, latestFileVersion,
                (String) workflowContext.get(WorkflowConstants.CONTEXT_URL), serviceContext);
    }
}

From source file:com.liferay.document.library.internal.verify.DLServiceVerifyProcess.java

License:Open Source License

protected void addDLFileVersion(DLFileEntry dlFileEntry) {
    long fileVersionId = _counterLocalService.increment();

    DLFileVersion dlFileVersion = _dlFileVersionLocalService.createDLFileVersion(fileVersionId);

    dlFileVersion.setGroupId(dlFileEntry.getGroupId());
    dlFileVersion.setCompanyId(dlFileEntry.getCompanyId());

    long userId = dlFileEntry.getUserId();

    dlFileVersion.setUserId(userId);/*from   ww  w  .  java  2s.com*/

    String userName = dlFileEntry.getUserName();

    dlFileVersion.setUserName(userName);

    dlFileVersion.setCreateDate(dlFileEntry.getModifiedDate());
    dlFileVersion.setModifiedDate(dlFileEntry.getModifiedDate());
    dlFileVersion.setRepositoryId(dlFileEntry.getRepositoryId());
    dlFileVersion.setFolderId(dlFileEntry.getFolderId());
    dlFileVersion.setFileEntryId(dlFileEntry.getFileEntryId());
    dlFileVersion.setExtension(dlFileEntry.getExtension());
    dlFileVersion.setMimeType(dlFileEntry.getMimeType());
    dlFileVersion.setTitle(dlFileEntry.getTitle());
    dlFileVersion.setDescription(dlFileEntry.getDescription());
    dlFileVersion.setExtraSettings(dlFileEntry.getExtraSettings());
    dlFileVersion.setFileEntryTypeId(dlFileEntry.getFileEntryTypeId());
    dlFileVersion.setVersion(dlFileEntry.getVersion());
    dlFileVersion.setSize(dlFileEntry.getSize());
    dlFileVersion.setStatus(WorkflowConstants.STATUS_APPROVED);
    dlFileVersion.setStatusByUserId(userId);
    dlFileVersion.setStatusByUserName(userName);
    dlFileVersion.setStatusDate(new Date());

    _dlFileVersionLocalService.updateDLFileVersion(dlFileVersion);
}

From source file:com.liferay.document.library.internal.verify.DLServiceVerifyProcess.java

License:Open Source License

protected void copyDLFileEntry(DLFileEntry dlFileEntry) throws PortalException {

    long companyId = dlFileEntry.getCompanyId();
    long dataRepositoryId = dlFileEntry.getDataRepositoryId();
    String name = dlFileEntry.getName();
    String version = dlFileEntry.getVersion();

    if (DLStoreUtil.hasFile(companyId, dataRepositoryId, name, version)) {
        return;/*w  w  w .  j a  v a2 s .c o  m*/
    }

    List<DLFileVersion> dlFileVersions = dlFileEntry.getFileVersions(WorkflowConstants.STATUS_APPROVED);

    if (dlFileVersions.isEmpty()) {
        dlFileVersions = dlFileEntry.getFileVersions(WorkflowConstants.STATUS_ANY);
    }

    if (dlFileVersions.isEmpty()) {
        DLStoreUtil.addFile(companyId, dataRepositoryId, name, new byte[0]);

        return;
    }

    dlFileVersions = ListUtil.copy(dlFileVersions);

    Collections.sort(dlFileVersions, new DLFileVersionVersionComparator());

    DLFileVersion dlFileVersion = dlFileVersions.get(0);

    DLStoreUtil.copyFileVersion(companyId, dataRepositoryId, name, dlFileVersion.getVersion(), version);
}

From source file:com.liferay.document.library.repository.external.model.ExtRepositoryFileEntryAdapter.java

License:Open Source License

@Override
@SuppressWarnings("rawtypes")
public List<FileVersion> getFileVersions(int status) {
    if ((status == WorkflowConstants.STATUS_ANY) || (status == WorkflowConstants.STATUS_APPROVED)) {

        try {/*from w  ww.  j ava  2 s  .co  m*/
            return (List) _getExtRepositoryFileVersionAdapters();
        } catch (PortalException pe) {
            throw new SystemException(pe);
        }
    } else {
        return Collections.emptyList();
    }
}