Example usage for com.liferay.portal.kernel.search Field STAGING_GROUP

List of usage examples for com.liferay.portal.kernel.search Field STAGING_GROUP

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.search Field STAGING_GROUP.

Prototype

String STAGING_GROUP

To view the source code for com.liferay.portal.kernel.search Field STAGING_GROUP.

Click Source Link

Usage

From source file:com.liferay.asset.search.test.AssetSearcherStagingTest.java

License:Open Source License

@Test
public void testSiteRolePermissions() throws Exception {
    Role role = addRole(RoleConstants.TYPE_SITE);

    String className = "com.liferay.journal.model.JournalArticle";

    RoleTestUtil.addResourcePermission(role, className, ResourceConstants.SCOPE_GROUP_TEMPLATE, "0",
            ActionKeys.VIEW);//from   w ww. j  av  a2  s. co  m

    User user = addUser();

    ServiceTestUtil.setUser(user);

    addUserGroupRole(user, role);

    addJournalArticle();

    GroupTestUtil.enableLocalStaging(_group);

    SearchContext searchContext = getSearchContext();

    Group stagingGroup = _group.getStagingGroup();

    searchContext.setGroupIds(new long[] { stagingGroup.getGroupId() });

    searchContext.setUserId(user.getUserId());

    QueryConfig queryConfig = searchContext.getQueryConfig();

    queryConfig.addSelectedFieldNames(Field.GROUP_ID, Field.STAGING_GROUP);

    AssetEntryQuery assetEntryQuery = getAssetEntryQuery(className);

    Hits hits = search(assetEntryQuery, searchContext);

    Document[] documents = hits.getDocs();

    DocumentsAssert.assertCount(hits.toString(), documents, Field.COMPANY_ID, 1);

    Document document = documents[0];

    assertField(document, Field.GROUP_ID, String.valueOf(stagingGroup.getGroupId()));
    assertField(document, Field.STAGING_GROUP, StringPool.TRUE);
}

From source file:com.liferay.calendar.search.test.CalendarBookingIndexerIndexedFieldsTest.java

License:Open Source License

@Test
public void testIndexedFields() throws Exception {
    String originalTitle = "entity title";
    String translatedTitle = "entitas neve";

    String description = StringUtil.toLowerCase(RandomTestUtil.randomString());

    CalendarBooking calendarBooking = addCalendarBooking(new LocalizedValuesMap() {
        {/*from  w w  w . ja  v a2  s .com*/
            put(LocaleUtil.US, originalTitle);
            put(LocaleUtil.HUNGARY, translatedTitle);
        }
    }, new LocalizedValuesMap() {
        {
            put(LocaleUtil.US, originalTitle);
            put(LocaleUtil.HUNGARY, translatedTitle);
        }
    }, new LocalizedValuesMap() {
        {
            put(LocaleUtil.US, description);
            put(LocaleUtil.HUNGARY, description);
        }
    });

    Map<String, String> map = new HashMap<>();

    map.put(Field.CLASS_NAME_ID, String.valueOf(portal.getClassNameId(Calendar.class)));

    map.put(Field.EXPIRATION_DATE, "99950812133000");
    map.put(Field.EXPIRATION_DATE.concat("_sortable"), "9223372036854775807");
    map.put(Field.PRIORITY, "0.0");
    map.put(Field.PUBLISH_DATE, "19700101000000");
    map.put(Field.PUBLISH_DATE.concat("_sortable"), "0");
    map.put(Field.RELATED_ENTRY, "true");
    map.put(Field.STAGING_GROUP, "false");
    map.put(Field.STATUS, "0");
    map.put("viewActionId", CalendarActionKeys.VIEW_BOOKING_DETAILS);

    populateTitle(originalTitle, map);

    populateTranslatedTitle(translatedTitle, map);

    CalendarResource calendarResource = calendarBooking.getCalendarResource();

    populateCalendarResource(calendarResource, map);

    Calendar calendar = calendarResource.getDefaultCalendar();

    populateCalendar(calendar, map);

    populateCalendarBooking(calendarBooking, map);

    DateFormat dateFormat = DateFormatFactoryUtil.getSimpleDateFormat("yyyyMMddHHmm");

    populateCalendarDate(Field.CREATE_DATE, calendar.getCreateDate(), dateFormat, map);
    populateCalendarDate(Field.MODIFIED_DATE, calendar.getModifiedDate(), dateFormat, map);

    calendarFieldsFixture.populateGroupRoleId(map);
    calendarFieldsFixture.populateRoleId("Owner", map);
    calendarFieldsFixture.populateUID(calendarBooking, map);

    String keywords = "nev";

    Document document = calendarSearchFixture.searchOnlyOne(keywords, LocaleUtil.HUNGARY);

    adjustDatePrecision(Field.CREATE_DATE, document, dateFormat);
    adjustDatePrecision(Field.MODIFIED_DATE, document, dateFormat);

    FieldValuesAssert.assertFieldValues(map, document, keywords);
}

From source file:com.liferay.calendar.search.test.CalendarIndexerIndexedFieldsTest.java

License:Open Source License

protected void populateExpectedFieldValues(Calendar calendar, Map<String, String> map) throws Exception {

    map.put(Field.COMPANY_ID, String.valueOf(calendar.getCompanyId()));
    map.put(Field.DEFAULT_LANGUAGE_ID, calendar.getDefaultLanguageId());
    map.put(Field.ENTRY_CLASS_NAME, calendar.getModelClassName());
    map.put(Field.ENTRY_CLASS_PK, String.valueOf(calendar.getCalendarId()));
    map.put(Field.GROUP_ID, String.valueOf(calendar.getGroupId()));
    map.put(Field.SCOPE_GROUP_ID, String.valueOf(calendar.getGroupId()));
    map.put(Field.STAGING_GROUP, "false");
    map.put(Field.USER_ID, String.valueOf(calendar.getUserId()));
    map.put(Field.USER_NAME, StringUtil.toLowerCase(calendar.getUserName()));
    map.put("calendarId", String.valueOf(calendar.getCalendarId()));

    DateFormat dateFormat = DateFormatFactoryUtil.getSimpleDateFormat("yyyyMMddHHmmss");

    populateCalendarDate(Field.CREATE_DATE, calendar.getCreateDate(), map, dateFormat);
    populateCalendarDate(Field.MODIFIED_DATE, calendar.getModifiedDate(), map, dateFormat);

    populateCalendarResource(calendar.getCalendarResource(), calendar, map);

    calendarFieldsFixture.populateGroupRoleId(map);
    calendarFieldsFixture.populateRoleId("Guest", map);
    calendarFieldsFixture.populateUID(calendar, map);
}