Search in sources :

Example 16 with DynamicQuery

use of com.liferay.portal.kernel.dao.orm.DynamicQuery in project liferay-ide by liferay.

the class ClubPersistenceTest method testDynamicQueryByPrimaryKeyMissing.

@Test
public void testDynamicQueryByPrimaryKeyMissing() throws Exception {
    DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Club.class, _dynamicQueryClassLoader);
    dynamicQuery.add(RestrictionsFactoryUtil.eq("clubId", RandomTestUtil.nextLong()));
    List<Club> result = _persistence.findWithDynamicQuery(dynamicQuery);
    Assert.assertEquals(0, result.size());
}
Also used : DynamicQuery(com.liferay.portal.kernel.dao.orm.DynamicQuery) ActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery) Club(com.liferay.roster.model.Club) Test(org.junit.Test)

Example 17 with DynamicQuery

use of com.liferay.portal.kernel.dao.orm.DynamicQuery in project liferay-ide by liferay.

the class RosterMemberPersistenceTest method testDynamicQueryByPrimaryKeyExisting.

@Test
public void testDynamicQueryByPrimaryKeyExisting() throws Exception {
    RosterMember newRosterMember = addRosterMember();
    DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(RosterMember.class, _dynamicQueryClassLoader);
    dynamicQuery.add(RestrictionsFactoryUtil.eq("rosterMemberId", newRosterMember.getRosterMemberId()));
    List<RosterMember> result = _persistence.findWithDynamicQuery(dynamicQuery);
    Assert.assertEquals(1, result.size());
    RosterMember existingRosterMember = result.get(0);
    Assert.assertEquals(existingRosterMember, newRosterMember);
}
Also used : RosterMember(com.liferay.roster.model.RosterMember) DynamicQuery(com.liferay.portal.kernel.dao.orm.DynamicQuery) ActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery) Test(org.junit.Test)

Example 18 with DynamicQuery

use of com.liferay.portal.kernel.dao.orm.DynamicQuery in project liferay-ide by liferay.

the class RosterPersistenceTest method testDynamicQueryByProjectionMissing.

@Test
public void testDynamicQueryByProjectionMissing() throws Exception {
    DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Roster.class, _dynamicQueryClassLoader);
    dynamicQuery.setProjection(ProjectionFactoryUtil.property("rosterId"));
    dynamicQuery.add(RestrictionsFactoryUtil.in("rosterId", new Object[] { RandomTestUtil.nextLong() }));
    List<Object> result = _persistence.findWithDynamicQuery(dynamicQuery);
    Assert.assertEquals(0, result.size());
}
Also used : DynamicQuery(com.liferay.portal.kernel.dao.orm.DynamicQuery) ActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery) Test(org.junit.Test)

Example 19 with DynamicQuery

use of com.liferay.portal.kernel.dao.orm.DynamicQuery in project liferay-ide by liferay.

the class RosterPersistenceTest method testDynamicQueryByProjectionExisting.

@Test
public void testDynamicQueryByProjectionExisting() throws Exception {
    Roster newRoster = addRoster();
    DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Roster.class, _dynamicQueryClassLoader);
    dynamicQuery.setProjection(ProjectionFactoryUtil.property("rosterId"));
    Object newRosterId = newRoster.getRosterId();
    dynamicQuery.add(RestrictionsFactoryUtil.in("rosterId", new Object[] { newRosterId }));
    List<Object> result = _persistence.findWithDynamicQuery(dynamicQuery);
    Assert.assertEquals(1, result.size());
    Object existingRosterId = result.get(0);
    Assert.assertEquals(existingRosterId, newRosterId);
}
Also used : Roster(com.liferay.roster.model.Roster) DynamicQuery(com.liferay.portal.kernel.dao.orm.DynamicQuery) ActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery) Test(org.junit.Test)

Example 20 with DynamicQuery

use of com.liferay.portal.kernel.dao.orm.DynamicQuery in project liferay-ide by liferay.

the class SongIndexer method reindexEntries.

protected void reindexEntries(long companyId) throws PortalException, SystemException {
    final Collection<Document> documents = new ArrayList<Document>();
    ActionableDynamicQuery actionableDynamicQuery = new SongActionableDynamicQuery() {

        @Override
        protected void addCriteria(DynamicQuery dynamicQuery) {
        }

        @Override
        protected void performAction(Object object) throws PortalException {
            Song song = (Song) object;
            Document document = getDocument(song);
            documents.add(document);
        }
    };
    actionableDynamicQuery.setCompanyId(companyId);
    actionableDynamicQuery.performActions();
    SearchEngineUtil.updateDocuments(getSearchEngineId(), companyId, documents);
}
Also used : SongActionableDynamicQuery(org.liferay.jukebox.service.persistence.SongActionableDynamicQuery) Song(org.liferay.jukebox.model.Song) DynamicQuery(com.liferay.portal.kernel.dao.orm.DynamicQuery) SongActionableDynamicQuery(org.liferay.jukebox.service.persistence.SongActionableDynamicQuery) ActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery) ArrayList(java.util.ArrayList) Document(com.liferay.portal.kernel.search.Document) SongActionableDynamicQuery(org.liferay.jukebox.service.persistence.SongActionableDynamicQuery) ActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery)

Aggregations

DynamicQuery (com.liferay.portal.kernel.dao.orm.DynamicQuery)23 ActionableDynamicQuery (com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery)21 Test (org.junit.Test)16 Foo (com.liferay.blade.samples.servicebuilder.model.Foo)4 Property (com.liferay.portal.kernel.dao.orm.Property)3 Document (com.liferay.portal.kernel.search.Document)3 Club (com.liferay.roster.model.Club)3 Roster (com.liferay.roster.model.Roster)3 RosterMember (com.liferay.roster.model.RosterMember)3 Conjunction (com.liferay.portal.kernel.dao.orm.Conjunction)2 Criterion (com.liferay.portal.kernel.dao.orm.Criterion)2 Disjunction (com.liferay.portal.kernel.dao.orm.Disjunction)2 Junction (com.liferay.portal.kernel.dao.orm.Junction)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ManifestSummary (com.liferay.exportimport.kernel.lar.ManifestSummary)1 StagedModelType (com.liferay.exportimport.kernel.lar.StagedModelType)1 KBArticle (com.liferay.knowledgebase.model.KBArticle)1 KBArticleActionableDynamicQuery (com.liferay.knowledgebase.service.persistence.KBArticleActionableDynamicQuery)1