use of com.liferay.portal.kernel.dao.orm.DynamicQuery in project liferay-ide by liferay.
the class RosterPersistenceTest method testDynamicQueryByPrimaryKeyMissing.
@Test
public void testDynamicQueryByPrimaryKeyMissing() throws Exception {
DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Roster.class, _dynamicQueryClassLoader);
dynamicQuery.add(RestrictionsFactoryUtil.eq("rosterId", RandomTestUtil.nextLong()));
List<Roster> result = _persistence.findWithDynamicQuery(dynamicQuery);
Assert.assertEquals(0, result.size());
}
use of com.liferay.portal.kernel.dao.orm.DynamicQuery in project liferay-ide by liferay.
the class ArtistIndexer method reindexEntries.
protected void reindexEntries(long companyId) throws PortalException, SystemException {
final Collection<Document> documents = new ArrayList<Document>();
ActionableDynamicQuery actionableDynamicQuery = new ArtistActionableDynamicQuery() {
@Override
protected void addCriteria(DynamicQuery dynamicQuery) {
}
@Override
protected void performAction(Object object) throws PortalException {
Artist artist = (Artist) object;
Document document = getDocument(artist);
documents.add(document);
}
};
actionableDynamicQuery.setCompanyId(companyId);
actionableDynamicQuery.performActions();
SearchEngineUtil.updateDocuments(getSearchEngineId(), companyId, documents);
}
use of com.liferay.portal.kernel.dao.orm.DynamicQuery in project liferay-ide by liferay.
the class KBArticleLocalServiceImpl method buildDynamicQuery.
protected DynamicQuery buildDynamicQuery(long groupId, String title, String content, int status, Date startDate, Date endDate, boolean andOperator) {
Junction junction = null;
if (andOperator) {
junction = RestrictionsFactoryUtil.conjunction();
} else {
junction = RestrictionsFactoryUtil.disjunction();
}
Map<String, String> terms = new HashMap<String, String>();
if (Validator.isNotNull(title)) {
terms.put("title", title);
}
if (Validator.isNotNull(content)) {
terms.put("content", content);
}
for (Map.Entry<String, String> entry : terms.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
Disjunction disjunction = RestrictionsFactoryUtil.disjunction();
for (String keyword : KnowledgeBaseUtil.splitKeywords(value)) {
Criterion criterion = RestrictionsFactoryUtil.ilike(key, StringUtil.quote(keyword, StringPool.PERCENT));
disjunction.add(criterion);
}
junction.add(disjunction);
}
if (status != WorkflowConstants.STATUS_ANY) {
Property property = PropertyFactoryUtil.forName("status");
junction.add(property.eq(status));
}
if ((endDate != null) && (startDate != null)) {
Disjunction disjunction = RestrictionsFactoryUtil.disjunction();
String[] propertyNames = { "createDate", "modifiedDate" };
for (String propertyName : propertyNames) {
Property property = PropertyFactoryUtil.forName(propertyName);
Conjunction conjunction = RestrictionsFactoryUtil.conjunction();
conjunction.add(property.gt(startDate));
conjunction.add(property.lt(endDate));
disjunction.add(conjunction);
}
junction.add(disjunction);
}
DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(KBArticle.class, getClassLoader());
if (status == WorkflowConstants.STATUS_ANY) {
Property property = PropertyFactoryUtil.forName("latest");
dynamicQuery.add(property.eq(Boolean.TRUE));
} else if (status == WorkflowConstants.STATUS_APPROVED) {
Property property = PropertyFactoryUtil.forName("main");
dynamicQuery.add(property.eq(Boolean.TRUE));
}
if (groupId > 0) {
Property property = PropertyFactoryUtil.forName("groupId");
dynamicQuery.add(property.eq(groupId));
}
return dynamicQuery.add(junction);
}
use of com.liferay.portal.kernel.dao.orm.DynamicQuery in project liferay-ide by liferay.
the class KBTemplateLocalServiceImpl method buildDynamicQuery.
protected DynamicQuery buildDynamicQuery(long groupId, String title, String content, Date startDate, Date endDate, boolean andOperator) {
Junction junction = null;
if (andOperator) {
junction = RestrictionsFactoryUtil.conjunction();
} else {
junction = RestrictionsFactoryUtil.disjunction();
}
Map<String, String> terms = new HashMap<String, String>();
if (Validator.isNotNull(title)) {
terms.put("title", title);
}
if (Validator.isNotNull(content)) {
terms.put("content", content);
}
for (Map.Entry<String, String> entry : terms.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
Disjunction disjunction = RestrictionsFactoryUtil.disjunction();
for (String keyword : KnowledgeBaseUtil.splitKeywords(value)) {
Criterion criterion = RestrictionsFactoryUtil.ilike(key, StringUtil.quote(keyword, StringPool.PERCENT));
disjunction.add(criterion);
}
junction.add(disjunction);
}
if ((endDate != null) && (startDate != null)) {
Disjunction disjunction = RestrictionsFactoryUtil.disjunction();
String[] propertyNames = { "createDate", "modifiedDate" };
for (String propertyName : propertyNames) {
Property property = PropertyFactoryUtil.forName(propertyName);
Conjunction conjunction = RestrictionsFactoryUtil.conjunction();
conjunction.add(property.gt(startDate));
conjunction.add(property.lt(endDate));
disjunction.add(conjunction);
}
junction.add(disjunction);
}
DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(KBTemplate.class, getClassLoader());
if (groupId > 0) {
Property property = PropertyFactoryUtil.forName("groupId");
dynamicQuery.add(property.eq(groupId));
}
return dynamicQuery.add(junction);
}
use of com.liferay.portal.kernel.dao.orm.DynamicQuery in project liferay-ide by liferay.
the class AdminIndexer method reindexKBArticles.
protected void reindexKBArticles(long companyId) throws Exception {
ActionableDynamicQuery actionableDynamicQuery = new KBArticleActionableDynamicQuery() {
@Override
protected void addCriteria(DynamicQuery dynamicQuery) {
Property property = PropertyFactoryUtil.forName("status");
dynamicQuery.add(property.eq(WorkflowConstants.STATUS_APPROVED));
}
@Override
protected void performAction(Object object) throws PortalException {
KBArticle kbArticle = (KBArticle) object;
Document document = getDocument(kbArticle);
addDocument(document);
}
};
actionableDynamicQuery.setCompanyId(companyId);
actionableDynamicQuery.setSearchEngineId(getSearchEngineId());
actionableDynamicQuery.performActions();
}
Aggregations