List of usage examples for com.liferay.portal.kernel.dao.orm ProjectionFactoryUtil sum
public static Projection sum(String propertyName)
From source file:com.cmcti.cmts.domain.service.impl.UpstreamChannelLocalServiceImpl.java
License:Open Source License
@SuppressWarnings("rawtypes") public List getSumCmCounts(DynamicQuery query) throws SystemException { // projection query.setProjection(//from ww w. j a v a2 s. c o m ProjectionFactoryUtil.projectionList().add(ProjectionFactoryUtil.sum("upChannelCmTotal")) .add(ProjectionFactoryUtil.sum("upChannelCmRegistered")) .add(ProjectionFactoryUtil.sum("upChannelCmActive"))); query.setLimit(0, 1); return dynamicQuery(query); }
From source file:com.liferay.message.boards.service.impl.MBStatsUserLocalServiceImpl.java
License:Open Source License
@Override public long getMessageCountByGroupId(long groupId) { DynamicQuery dynamicQuery = mbStatsUserLocalService.dynamicQuery(); Projection projection = ProjectionFactoryUtil.sum("messageCount"); dynamicQuery.setProjection(projection); Property property = PropertyFactoryUtil.forName("groupId"); dynamicQuery.add(property.eq(groupId)); List<Long> results = mbStatsUserLocalService.dynamicQuery(dynamicQuery); if (results.get(0) == null) { return 0; }/*from ww w. j a va2s. com*/ return results.get(0); }
From source file:com.liferay.message.boards.service.impl.MBStatsUserLocalServiceImpl.java
License:Open Source License
@Override public long getMessageCountByUserId(long userId) { DynamicQuery dynamicQuery = mbStatsUserLocalService.dynamicQuery(); Projection projection = ProjectionFactoryUtil.sum("messageCount"); dynamicQuery.setProjection(projection); Property property = PropertyFactoryUtil.forName("userId"); dynamicQuery.add(property.eq(userId)); List<Long> results = mbStatsUserLocalService.dynamicQuery(dynamicQuery); if (results.get(0) == null) { return 0; }/*from w ww . java2s .c om*/ return results.get(0); }
From source file:com.liferay.portlet.messageboards.service.impl.MBStatsUserLocalServiceImpl.java
License:Open Source License
public long getMessageCountByUserId(long userId) throws SystemException { DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(MBStatsUser.class, MBStatsUserImpl.TABLE_NAME, PortalClassLoaderUtil.getClassLoader()); dynamicQuery.setProjection(ProjectionFactoryUtil.sum("messageCount")); dynamicQuery.add(PropertyFactoryUtil.forName("userId").eq(userId)); List<Long> results = mbStatsUserLocalService.dynamicQuery(dynamicQuery); if (results.isEmpty()) { return 0; }/*from w ww.j a v a 2 s .c o m*/ return results.get(0); }
From source file:de.fraunhofer.fokus.movepla.service.impl.LoggingLocalServiceImpl.java
License:Open Source License
public List<Logging> getMostUsedSearchStringInclNull() { List<Logging> resultList = new ArrayList<Logging>(); try {//w w w. j a v a2 s .c om DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Logging.class); ProjectionList projectionList = ProjectionFactoryUtil.projectionList(); projectionList.add(ProjectionFactoryUtil.groupProperty("searchString")); projectionList.add(ProjectionFactoryUtil.sum("passel")); dynamicQuery.setProjection(projectionList); Order defaultOrder = OrderFactoryUtil.desc("passel"); dynamicQuery.addOrder(defaultOrder); List result = dynamicQuery(dynamicQuery); _log.info(result.size()); Iterator it = result.iterator(); if (!it.hasNext()) { _log.info("No any data!"); } else { while (it.hasNext()) { Logging log = new LoggingImpl(); Object[] row = (Object[]) it.next(); // for(int i = 0; i < row.length;i++) { // _log.info(row[i]); // } log.setSearchString(String.valueOf(row[0])); log.setPassel(Long.parseLong(String.valueOf(row[1]))); resultList.add(log); } } } catch (Exception e) { _log.info("Exception: " + e.getMessage()); } return resultList; }
From source file:de.fraunhofer.fokus.movepla.service.impl.LoggingLocalServiceImpl.java
License:Open Source License
public List<Logging> getLoggingsByCategories() { List<Logging> resultList = new ArrayList<Logging>(); List<Logging> tmpApplications = new ArrayList<Logging>(); try {//from w ww . java 2 s.com List<Category> allCategories = CategoryLocalServiceUtil.getCategories(10154); for (Category category : allCategories) { String catIdString = String.valueOf(category.getCategoryId()); DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Logging.class); ProjectionList projectionList = ProjectionFactoryUtil.projectionList(); projectionList.add(ProjectionFactoryUtil.sum("passel")); dynamicQuery.setProjection(projectionList); // only one category Criterion criterion = RestrictionsFactoryUtil.like("categoryIDString", catIdString); // categoryId at the beginning criterion = RestrictionsFactoryUtil.or(criterion, RestrictionsFactoryUtil.like("categoryIDString", catIdString + ";" + StringPool.PERCENT)); // categoryId at the end criterion = RestrictionsFactoryUtil.or(criterion, RestrictionsFactoryUtil.like("categoryIDString", StringPool.PERCENT + ";" + catIdString)); // categoryId in the middle criterion = RestrictionsFactoryUtil.or(criterion, RestrictionsFactoryUtil.like("categoryIDString", StringPool.PERCENT + ";" + catIdString + ";" + StringPool.PERCENT)); dynamicQuery.add(criterion); Order defaultOrder = OrderFactoryUtil.desc("passel"); dynamicQuery.addOrder(defaultOrder); List<Long> result = dynamicQuery(dynamicQuery); // _log.info("catIdString::result.size(): " + catIdString + "::" + result.size()); if (result.size() > 0) { // _log.info("result.get(0): " + result.get(0)); if (result.get(0) != null) { Logging log = new LoggingImpl(); log.setCategoryIDString(category.getCategoryName()); long _p = result.get(0); // _log.info("_p: " + _p); log.setPassel(_p); tmpApplications.add(log); // _log.info("tmpApplications.size(): " + tmpApplications.size()); } else { continue; } } } resultList.addAll(tmpApplications); OrderByComparator orderByComparator = CustomComparatorUtil.getLoggingOrderByComparator("passel", "desc"); Collections.sort(resultList, orderByComparator); } catch (Exception e) { _log.info("Exception: " + e.getMessage()); e.printStackTrace(); } return resultList; }
From source file:de.fraunhofer.fokus.movepla.service.impl.LoggingLocalServiceImpl.java
License:Open Source License
public List<Logging> getLoggingsByRegions() { List<Logging> resultList = new ArrayList<Logging>(); List<Logging> tmpApplications = new ArrayList<Logging>(); try {/*from w w w . j a va2 s .c om*/ List<Region> allRegions = RegionLocalServiceUtil.findByc(10154); for (Region region : allRegions) { String regIdString = String.valueOf(region.getRegionId()); DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Logging.class); ProjectionList projectionList = ProjectionFactoryUtil.projectionList(); projectionList.add(ProjectionFactoryUtil.sum("passel")); dynamicQuery.setProjection(projectionList); // only one category Criterion criterion = RestrictionsFactoryUtil.like("regionIDString", regIdString); // categoryId at the beginning criterion = RestrictionsFactoryUtil.or(criterion, RestrictionsFactoryUtil.like("regionIDString", regIdString + ";" + StringPool.PERCENT)); // categoryId at the end criterion = RestrictionsFactoryUtil.or(criterion, RestrictionsFactoryUtil.like("regionIDString", StringPool.PERCENT + ";" + regIdString)); // categoryId in the middle criterion = RestrictionsFactoryUtil.or(criterion, RestrictionsFactoryUtil.like("regionIDString", StringPool.PERCENT + ";" + regIdString + ";" + StringPool.PERCENT)); dynamicQuery.add(criterion); Order defaultOrder = OrderFactoryUtil.desc("passel"); dynamicQuery.addOrder(defaultOrder); List<Long> result = dynamicQuery(dynamicQuery); if (result.size() > 0) { if (result.get(0) != null) { Logging log = new LoggingImpl(); log.setRegionIDString(region.getName()); long _p = result.get(0); log.setPassel(_p); tmpApplications.add(log); } else { continue; } } } resultList.addAll(tmpApplications); OrderByComparator orderByComparator = CustomComparatorUtil.getLoggingOrderByComparator("passel", "desc"); Collections.sort(resultList, orderByComparator); } catch (Exception e) { _log.info("Exception: " + e.getMessage()); e.printStackTrace(); } return resultList; }
From source file:de.fraunhofer.fokus.movepla.service.impl.LoggingLocalServiceImpl.java
License:Open Source License
public List<Logging> getLoggingsByMissingEntitlements() { List<Logging> resultList = new ArrayList<Logging>(); List<Logging> tmpApplications = new ArrayList<Logging>(); try {/*from w w w. j a v a 2 s. c om*/ List<Entitlement> allEntitlements = EntitlementLocalServiceUtil.getEntitlements(10154); for (Entitlement entitlement : allEntitlements) { String entitlementIdString = String.valueOf(entitlement.getEntitlementId()); DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Logging.class); ProjectionList projectionList = ProjectionFactoryUtil.projectionList(); projectionList.add(ProjectionFactoryUtil.sum("passel")); dynamicQuery.setProjection(projectionList); // only one category Criterion criterion = RestrictionsFactoryUtil .not(RestrictionsFactoryUtil.like("entitlementIDString", entitlementIdString)); // categoryId at the beginning criterion = RestrictionsFactoryUtil.and(criterion, RestrictionsFactoryUtil.not(RestrictionsFactoryUtil.like("entitlementIDString", entitlementIdString + ";" + StringPool.PERCENT))); // categoryId at the end criterion = RestrictionsFactoryUtil.and(criterion, RestrictionsFactoryUtil.not(RestrictionsFactoryUtil.like("entitlementIDString", StringPool.PERCENT + ";" + entitlementIdString))); // categoryId in the middle criterion = RestrictionsFactoryUtil.and(criterion, RestrictionsFactoryUtil.not(RestrictionsFactoryUtil.like("entitlementIDString", StringPool.PERCENT + ";" + entitlementIdString + ";" + StringPool.PERCENT))); dynamicQuery.add(criterion); Order defaultOrder = OrderFactoryUtil.desc("passel"); dynamicQuery.addOrder(defaultOrder); List<Long> result = dynamicQuery(dynamicQuery); if (result.size() > 0) { if (result.get(0) != null) { Logging log = new LoggingImpl(); log.setEntitlementIDString(entitlement.getEntitlementName()); long _p = result.get(0); log.setPassel(_p); tmpApplications.add(log); } else { continue; } } } resultList.addAll(tmpApplications); OrderByComparator orderByComparator = CustomComparatorUtil.getLoggingOrderByComparator("passel", "desc"); Collections.sort(resultList, orderByComparator); } catch (Exception e) { _log.info("Exception: " + e.getMessage()); e.printStackTrace(); } return resultList; }
From source file:de.fraunhofer.fokus.movepla.service.impl.LoggingLocalServiceImpl.java
License:Open Source License
public List<Logging> getLoggingsByPlatforms() { List<Logging> resultList = new ArrayList<Logging>(); List<Logging> tmpApplications = new ArrayList<Logging>(); try {//w w w .j a v a 2s . com List<String> allPlatforms = new ArrayList<String>(); allPlatforms.add("android"); allPlatforms.add("ios"); allPlatforms.add("webapp"); allPlatforms.add("windows"); allPlatforms.add("blackberry"); allPlatforms.add("ubuntu"); for (String platform : allPlatforms) { DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Logging.class); ProjectionList projectionList = ProjectionFactoryUtil.projectionList(); projectionList.add(ProjectionFactoryUtil.sum("passel")); dynamicQuery.setProjection(projectionList); // only one category Criterion criterion = RestrictionsFactoryUtil.like("targetOS", platform); // categoryId at the beginning criterion = RestrictionsFactoryUtil.or(criterion, RestrictionsFactoryUtil.like("targetOS", platform + ";" + StringPool.PERCENT)); // categoryId at the end criterion = RestrictionsFactoryUtil.or(criterion, RestrictionsFactoryUtil.like("targetOS", StringPool.PERCENT + ";" + platform)); // categoryId in the middle criterion = RestrictionsFactoryUtil.or(criterion, RestrictionsFactoryUtil.like("targetOS", StringPool.PERCENT + ";" + platform + ";" + StringPool.PERCENT)); dynamicQuery.add(criterion); Order defaultOrder = OrderFactoryUtil.desc("passel"); dynamicQuery.addOrder(defaultOrder); List<Long> result = dynamicQuery(dynamicQuery); if (result.size() > 0) { if (result.get(0) != null) { Logging log = new LoggingImpl(); log.setTargetOS(platform); long _p = result.get(0); log.setPassel(_p); tmpApplications.add(log); } else { continue; } } } resultList.addAll(tmpApplications); OrderByComparator orderByComparator = CustomComparatorUtil.getLoggingOrderByComparator("passel", "desc"); Collections.sort(resultList, orderByComparator); } catch (Exception e) { _log.info("Exception: " + e.getMessage()); e.printStackTrace(); } return resultList; }
From source file:de.fraunhofer.fokus.movepla.service.impl.LoggingLocalServiceImpl.java
License:Open Source License
public List<Logging> getLoggingsByTargetCategories() { List<Logging> resultList = new ArrayList<Logging>(); List<Logging> tmpApplications = new ArrayList<Logging>(); try {/* ww w . ja v a 2 s . co m*/ List<String> allTargetCategories = new ArrayList<String>(); allTargetCategories.add("Smartphone"); allTargetCategories.add("Tablet"); for (String targetCategory : allTargetCategories) { DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Logging.class); ProjectionList projectionList = ProjectionFactoryUtil.projectionList(); projectionList.add(ProjectionFactoryUtil.sum("passel")); dynamicQuery.setProjection(projectionList); // only one category Criterion criterion = RestrictionsFactoryUtil.like("targetCategory", targetCategory); // categoryId at the beginning criterion = RestrictionsFactoryUtil.or(criterion, RestrictionsFactoryUtil.like("targetCategory", targetCategory + ";" + StringPool.PERCENT)); // categoryId at the end criterion = RestrictionsFactoryUtil.or(criterion, RestrictionsFactoryUtil.like("targetCategory", StringPool.PERCENT + ";" + targetCategory)); // categoryId in the middle criterion = RestrictionsFactoryUtil.or(criterion, RestrictionsFactoryUtil.like("targetCategory", StringPool.PERCENT + ";" + targetCategory + ";" + StringPool.PERCENT)); dynamicQuery.add(criterion); Order defaultOrder = OrderFactoryUtil.desc("passel"); dynamicQuery.addOrder(defaultOrder); List<Long> result = dynamicQuery(dynamicQuery); if (result.size() > 0) { if (result.get(0) != null) { Logging log = new LoggingImpl(); log.setTargetCategory(targetCategory); long _p = result.get(0); log.setPassel(_p); tmpApplications.add(log); } else { continue; } } } resultList.addAll(tmpApplications); OrderByComparator orderByComparator = CustomComparatorUtil.getLoggingOrderByComparator("passel", "desc"); Collections.sort(resultList, orderByComparator); } catch (Exception e) { _log.info("Exception: " + e.getMessage()); e.printStackTrace(); } return resultList; }