org.hibernate.criterion.Projections.property()

Here are the examples of the java api org.hibernate.criterion.Projections.property() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

70 Examples 7

19 Source : RegionStatusDaoImpl.java
with Apache License 2.0
from tmobile

/**
 * Gets the platform of Parent Component
 *
 * @param allParentComponentsStatusMap
 * @return
 */
public String getParentPlatform(int parentComponentId, int envId) {
    Session session = sessionFactory.openSession();
    Criteria healthCheckCriteria = session.createCriteria(HealthCheckEnreplacedy.clreplaced);
    healthCheckCriteria.add(Restrictions.eq("delInd", 0));
    if (envId != 0) {
        healthCheckCriteria.add(Restrictions.eq("environment.environmentId", envId));
    }
    healthCheckCriteria.createCriteria("component", "comp");
    healthCheckCriteria.add(Restrictions.eq("comp.parentComponent.componentId", parentComponentId));
    healthCheckCriteria.setProjection(Projections.distinct(Projections.property("comp.platform")));
    healthCheckCriteria.addOrder(Order.asc("comp.platform"));
    List<Object[]> pformList = healthCheckCriteria.list();
    List<String> pform = new ArrayList<String>();
    for (Object aRow : pformList) {
        if (aRow != null) {
            pform.add(aRow.toString());
        }
    }
    String platform = String.join("/", pform);
    session.close();
    return platform;
}

19 Source : ItemSerializerState.java
with Apache License 2.0
from openequella

public void addStatusQuery() {
    if (!statusAdded) {
        itemProjection.add(Projections.property("status"), STATUS_ALIAS);
        statusAdded = true;
    }
}

19 Source : ItemSerializerState.java
with Apache License 2.0
from openequella

public void addCollectionQuery() {
    if (!collectionAdded) {
        itemQuery.createAlias("itemDefinition", "col");
        itemProjection.add(Projections.property("col.uuid"), COLLECTIONUUID_ALIAS);
        itemProjection.add(Projections.property("col.id"), COLLECTIONID_ALIAS);
        collectionAdded = true;
    }
}

19 Source : ItemSerializerState.java
with Apache License 2.0
from openequella

public void addOwnerQuery() {
    if (!ownerQueryAdded) {
        itemProjection.add(Projections.property("owner"), OWNER_ALIAS);
        ownerQueryAdded = true;
    }
}

19 Source : DrmSerializerProvider.java
with Apache License 2.0
from openequella

@Override
public void prepareItemQuery(ItemSerializerState state) {
    if (state.hasCategory(CATEGORY_DRM)) {
        state.gereplacedemProjection().add(Projections.property("drmSettings"), ALIAS_DRM);
    }
}

18 Source : MoneyTransferDaoImpl.java
with GNU Lesser General Public License v2.1
from phoenixctms

@Override
protected long handleGetCostTypeCount(Long probandId, Long trialId) throws Exception {
    org.hibernate.Criteria moneyTransferCriteria = createMoneyTransferCriteria(null);
    applyCostTypeCriterions(moneyTransferCriteria, probandId, trialId);
    // return (Long) moneyTransferCriteria.setProjection(Projections.countDistinct("costType")).uniqueResult();
    // postgres: count(distinct f1) yields the number of distinct ***non-null*** values of f1
    moneyTransferCriteria.setProjection(Projections.distinct(Projections.property("costType")));
    return moneyTransferCriteria.list().size();
}

18 Source : MoneyTransferDaoImpl.java
with GNU Lesser General Public License v2.1
from phoenixctms

@Override
protected long handleGetCostTypeCount(Long probandId, Long trialId, String costType) throws Exception {
    org.hibernate.Criteria moneyTransferCriteria = createMoneyTransferCriteria(null);
    applyCostTypeCriterions(moneyTransferCriteria, probandId, trialId);
    CategoryCriterion.apply(moneyTransferCriteria, new CategoryCriterion(costType, "costType", MatchMode.EXACT, EmptyPrefixModes.EMPTY_ROWS));
    // return (Long) moneyTransferCriteria.setProjection(Projections.countDistinct("costType")).uniqueResult();
    // postgres: count(distinct f1) yields the number of distinct ***non-null*** values of f1
    moneyTransferCriteria.setProjection(Projections.distinct(Projections.property("costType")));
    return moneyTransferCriteria.list().size();
}

18 Source : InquiryDaoImpl.java
with GNU Lesser General Public License v2.1
from phoenixctms

@Override
protected Collection<String> handleFindCategories(Long trialId, String categoryPrefix, Boolean active, Boolean activeSignup, Integer limit) throws Exception {
    org.hibernate.Criteria inquiryCriteria = createInquiryCriteria();
    if (trialId != null) {
        inquiryCriteria.add(Restrictions.eq("trial.id", trialId.longValue()));
    }
    if (active != null) {
        inquiryCriteria.add(Restrictions.eq("active", active.booleanValue()));
    }
    if (activeSignup != null) {
        inquiryCriteria.add(Restrictions.eq("activeSignup", activeSignup.booleanValue()));
    }
    CategoryCriterion.apply(inquiryCriteria, new CategoryCriterion(categoryPrefix, "category", MatchMode.START));
    inquiryCriteria.addOrder(Order.asc("category"));
    inquiryCriteria.setProjection(Projections.distinct(Projections.property("category")));
    CriteriaUtil.applyLimit(limit, Settings.getIntNullable(SettingCodes.INQUIRY_CATEGORY_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT, Bundle.SETTINGS, DefaultSettings.INQUIRY_CATEGORY_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT), inquiryCriteria);
    return inquiryCriteria.list();
}

18 Source : ECRFFieldDaoImpl.java
with GNU Lesser General Public License v2.1
from phoenixctms

@Override
protected Collection<String> handleFindSections(Long trialId, Long ecrfId, String sectionPrefix, Integer limit) throws Exception {
    org.hibernate.Criteria ecrfFieldCriteria = createEcrfFieldCriteria();
    if (trialId != null) {
        ecrfFieldCriteria.add(Restrictions.eq("trial.id", trialId.longValue()));
    }
    if (ecrfId != null) {
        ecrfFieldCriteria.add(Restrictions.eq("ecrf.id", ecrfId.longValue()));
    }
    CategoryCriterion.apply(ecrfFieldCriteria, new CategoryCriterion(sectionPrefix, "section", MatchMode.START));
    ecrfFieldCriteria.addOrder(Order.asc("section"));
    ecrfFieldCriteria.setProjection(Projections.distinct(Projections.property("section")));
    CriteriaUtil.applyLimit(limit, Settings.getIntNullable(SettingCodes.ECRF_FIELD_SECTION_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT, Bundle.SETTINGS, DefaultSettings.ECRF_FIELD_SECTION_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT), ecrfFieldCriteria);
    return ecrfFieldCriteria.list();
}

18 Source : ItemSerializerState.java
with Apache License 2.0
from openequella

public void addPrivilege(String priv) {
    if (privileges.isEmpty()) {
        addOwnerQuery();
        addCollectionQuery();
        addStatusQuery();
        itemProjection.add(Projections.property("metadataSecurityTargets"), SECURITY_ALIAS);
    }
    privileges.add(priv);
}

18 Source : NavigationNodeSerializerProvider.java
with Apache License 2.0
from openequella

@Override
public void prepareItemQuery(ItemSerializerState state) {
    if (state.hasCategory(CATEGORY_NAVIGATION)) {
        state.addPrivilege(ItemSecurityConstants.VIEW_ITEM);
        final ProjectionList projection = state.gereplacedemProjection();
        projection.add(Projections.property("navigationSettings.manualNavigation"), ALIAS_MANUAL_NAVIGATION);
        projection.add(Projections.property("navigationSettings.showSplitOption"), ALIAS_SHOW_SPLIT);
    }
}

17 Source : HibernateScanResultFilterDao.java
with Mozilla Public License 2.0
from secdec

@Override
public List<GenericSeverity> loadFilteredSeveritiesForChannelType(ChannelType channelType) {
    Criteria criteria = sessionFactory.getCurrentSession().createCriteria(ScanResultFilter.clreplaced).add(Restrictions.eq("channelType", channelType)).setProjection(Projections.property("genericSeverity"));
    return criteria.list();
}

17 Source : CriteriaUtil.java
with GNU Lesser General Public License v2.1
from phoenixctms

public static List listDistinctRoot(Criteria criteria, Object dao, String... distinctProjections) throws Exception {
    if (dao != null && criteria != null) {
        criteria.setProjection(null);
        criteria.setResultTransformer(CriteriaSpecification.ROOT_ENreplacedY);
        Method loadMethod = CoreUtil.getDaoLoadMethod(dao);
        ProjectionList projectionList = Projections.projectionList().add(Projections.id());
        boolean cast = false;
        if (distinctProjections != null && distinctProjections.length > 0) {
            SubCriteriaMap criteriaMap = new SubCriteriaMap(loadMethod.getReturnType(), criteria);
            for (int i = 0; i < distinctProjections.length; i++) {
                replacedociationPath distinctProjectionreplacedociationPath = new replacedociationPath(distinctProjections[i]);
                Criteria projectioncriteria = getProjectionCriteria(criteriaMap, distinctProjectionreplacedociationPath);
                if (projectioncriteria != null) {
                    projectionList.add(Projections.property(distinctProjectionreplacedociationPath.getFullQualifiedPropertyName()));
                    cast = true;
                }
            }
        }
        List items = criteria.setProjection(Projections.distinct(projectionList)).list();
        Iterator it = items.iterator();
        ArrayList result = new ArrayList(items.size());
        while (it.hasNext()) {
            result.add(loadMethod.invoke(dao, cast ? ((Object[]) it.next())[0] : it.next()));
        }
        return result;
    }
    return null;
}

17 Source : MoneyTransferDaoImpl.java
with GNU Lesser General Public License v2.1
from phoenixctms

@Override
protected Collection<String> handleGetCostTypes(Long trialDepartmentId, Long trialId, Long probandDepartmentId, Long probandId, PaymentMethod method) throws Exception {
    org.hibernate.Criteria moneyTransferCriteria = createMoneyTransferCriteria("moneyTransfer");
    if (method != null) {
        moneyTransferCriteria.add(Restrictions.eq("method", method));
    }
    applyCostTypeCriterions(moneyTransferCriteria, trialDepartmentId, trialId, probandDepartmentId, probandId);
    moneyTransferCriteria.setProjection(Projections.distinct(Projections.property("costType")));
    List<String> result = moneyTransferCriteria.list();
    // match TreeMaps!
    Collections.sort(result, ServiceUtil.MONEY_TRANSFER_COST_TYPE_COMPARATOR);
    return result;
}

17 Source : MoneyTransferDaoImpl.java
with GNU Lesser General Public License v2.1
from phoenixctms

@Override
protected Collection<String> handleFindCostTypes(Long trialDepartmentId, Long trialId, Long probandDepartmentId, Long probandId, String costTypePrefix, Integer limit) throws Exception {
    org.hibernate.Criteria moneyTransferCriteria = createMoneyTransferCriteria("moneyTransfer");
    applyCostTypeCriterions(moneyTransferCriteria, trialDepartmentId, trialId, probandDepartmentId, probandId);
    CategoryCriterion.apply(moneyTransferCriteria, new CategoryCriterion(costTypePrefix, "costType", MatchMode.START));
    moneyTransferCriteria.addOrder(Order.asc("costType"));
    moneyTransferCriteria.setProjection(Projections.distinct(Projections.property("costType")));
    CriteriaUtil.applyLimit(limit, Settings.getIntNullable(SettingCodes.MONEY_TRANSFER_COST_TYPE_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT, Bundle.SETTINGS, DefaultSettings.MONEY_TRANSFER_COST_TYPE_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT), moneyTransferCriteria);
    return moneyTransferCriteria.list();
}

17 Source : MimeTypeDaoImpl.java
with GNU Lesser General Public License v2.1
from phoenixctms

@Override
protected Collection<String> handleFindFileNameExtensions(FileModule module, Boolean image) throws Exception {
    org.hibernate.Criteria mimeTypeCriteria = createMimeTypeCriteria();
    if (module != null) {
        mimeTypeCriteria.add(Restrictions.eq("module", module));
    }
    if (image != null) {
        mimeTypeCriteria.add(Restrictions.eq("image", image.booleanValue()));
    }
    mimeTypeCriteria.setProjection(Projections.distinct(Projections.property("fileNameExtensions")));
    return mimeTypeCriteria.list();
}

17 Source : InputFieldDaoImpl.java
with GNU Lesser General Public License v2.1
from phoenixctms

@Override
protected Collection<String> handleFindCategories(InputFieldType fieldType, String categoryPrefix, Integer limit) throws Exception {
    org.hibernate.Criteria inputFieldCriteria = createInputFieldCriteria();
    if (fieldType != null) {
        inputFieldCriteria.add(Restrictions.eq("fieldType", fieldType));
    }
    CategoryCriterion.apply(inputFieldCriteria, new CategoryCriterion(categoryPrefix, "category", MatchMode.START));
    inputFieldCriteria.addOrder(Order.asc("category"));
    inputFieldCriteria.setProjection(Projections.distinct(Projections.property("category")));
    CriteriaUtil.applyLimit(limit, Settings.getIntNullable(SettingCodes.INPUT_FIELD_CATEGORY_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT, Bundle.SETTINGS, DefaultSettings.INPUT_FIELD_CATEGORY_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT), inputFieldCriteria);
    return inputFieldCriteria.list();
}

17 Source : FileDaoImpl.java
with GNU Lesser General Public License v2.1
from phoenixctms

@Override
protected Collection<String> handleFindFileFolders(FileModule module, Long id, String parentLogicalPath, boolean complete, Boolean active, Boolean publicFile, Boolean image, PSFVO psf) throws Exception {
    org.hibernate.Criteria fileFolderPresetCriteria = this.getSession().createCriteria(FileFolderPreset.clreplaced);
    fileFolderPresetCriteria.setCacheable(true);
    boolean useParentPath;
    ArrayList<String> result = new ArrayList<String>();
    HashSet<String> dupeCheck = new HashSet<String>(result);
    String parentLogicalFolder = CommonUtil.fixLogicalPathFolderName(parentLogicalPath, !complete);
    int depth;
    PSFVO f;
    if (psf != null) {
        f = new PSFVO();
        f.setFilters(psf.getFilters());
    } else {
        f = null;
    }
    fileFolderPresetCriteria.add(Restrictions.eq("module", module));
    if (parentLogicalPath != null && parentLogicalPath.length() > 0) {
        fileFolderPresetCriteria.add(Restrictions.like("logicalPath", parentLogicalFolder, MatchMode.START));
        depth = CommonUtil.getLogicalPathFolderDepth(parentLogicalFolder);
        useParentPath = true;
    } else {
        depth = 0;
        useParentPath = false;
    }
    Integer limit = complete ? Settings.getIntNullable(SettingCodes.FILE_FOLDER_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT, Bundle.SETTINGS, DefaultSettings.FILE_FOLDER_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT) : null;
    if (f == null || f.getFilters() == null || f.getFilters().size() == 0) {
        fileFolderPresetCriteria.setProjection(Projections.distinct(Projections.property("logicalPath")));
        Iterator<String> folderPresereplaced = fileFolderPresetCriteria.list().iterator();
        while (folderPresereplaced.hasNext()) {
            if (limit != null && limit >= 0 && result.size() >= limit) {
                break;
            }
            String folder = folderPresereplaced.next();
            if (CommonUtil.getLogicalPathFolderDepth(folder) > depth) {
                folder = CommonUtil.getLogicalPathFolderToDepth(folder, depth + 1);
                if (dupeCheck.add(folder)) {
                    result.add(folder);
                }
            }
        }
    }
    if (id != null) {
        org.hibernate.Criteria fileCriteria = createFileCriteria();
        SubCriteriaMap criteriaMap = new SubCriteriaMap(File.clreplaced, fileCriteria);
        applyModuleIdCriterions(fileCriteria, module, id);
        if (useParentPath) {
            fileCriteria.add(Restrictions.like("logicalPath", parentLogicalFolder, MatchMode.START));
        }
        if (active != null) {
            fileCriteria.add(Restrictions.eq("active", active.booleanValue()));
        }
        if (publicFile != null) {
            fileCriteria.add(Restrictions.eq("publicFile", publicFile.booleanValue()));
        }
        applyContentTypeCriterions(fileCriteria, image, null);
        CriteriaUtil.applyPSFVO(criteriaMap, f);
        fileCriteria.setProjection(Projections.distinct(Projections.property("logicalPath")));
        Iterator<String> fileFolderIt = fileCriteria.list().iterator();
        while (fileFolderIt.hasNext()) {
            if (limit != null && limit >= 0 && result.size() >= limit) {
                break;
            }
            String folder = fileFolderIt.next();
            if (CommonUtil.getLogicalPathFolderDepth(folder) > depth) {
                folder = CommonUtil.getLogicalPathFolderToDepth(folder, depth + 1);
                if (dupeCheck.add(folder)) {
                    result.add(folder);
                }
            }
        }
    }
    Collections.sort(result, new AlphanumStringComparator(false));
    return result;
}

16 Source : DaoUtil.java
with Apache License 2.0
from tmobile

public static ProjectionList getContainerStatusProjectionList() {
    ProjectionList projectionList = Projections.projectionList();
    projectionList.add(Projections.property("component.parentComponent.componentId"));
    projectionList.add(Projections.property("contSts.statusDate"));
    projectionList.add(Projections.sum("contSts.totalContainers"));
    projectionList.add(Projections.groupProperty("component.parentComponent.componentId"));
    projectionList.add(Projections.groupProperty("contSts.statusDate"));
    return projectionList;
}

16 Source : MoneyTransferDaoImpl.java
with GNU Lesser General Public License v2.1
from phoenixctms

@Override
protected Collection<String> handleGetCostTypesNoTrial(Long probandId, PaymentMethod method) throws Exception {
    org.hibernate.Criteria moneyTransferCriteria = createMoneyTransferCriteria("moneyTransfer");
    if (method != null) {
        moneyTransferCriteria.add(Restrictions.eq("method", method));
    }
    moneyTransferCriteria.add(Restrictions.isNull("trial.id"));
    moneyTransferCriteria.add(Restrictions.eq("proband.id", probandId.longValue()));
    moneyTransferCriteria.setProjection(Projections.distinct(Projections.property("costType")));
    List<String> result = moneyTransferCriteria.list();
    // match TreeMaps!
    Collections.sort(result, ServiceUtil.MONEY_TRANSFER_COST_TYPE_COMPARATOR);
    return result;
}

16 Source : MedicationDaoImpl.java
with GNU Lesser General Public License v2.1
from phoenixctms

@Override
protected Collection<String> handleFindDoseUnits(String doseUnitPrefix, Integer limit) throws Exception {
    org.hibernate.Criteria medicationCriteria = createMedicationCriteria();
    CategoryCriterion.apply(medicationCriteria, new CategoryCriterion(doseUnitPrefix, "doseUnit", MatchMode.START));
    medicationCriteria.add(Restrictions.not(Restrictions.or(Restrictions.eq("doseUnit", ""), Restrictions.isNull("doseUnit"))));
    medicationCriteria.addOrder(Order.asc("doseUnit"));
    medicationCriteria.setProjection(Projections.distinct(Projections.property("doseUnit")));
    CriteriaUtil.applyLimit(limit, Settings.getIntNullable(SettingCodes.MEDICATION_DOSE_UNIT_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT, Bundle.SETTINGS, DefaultSettings.MEDICATION_DOSE_UNIT_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT), medicationCriteria);
    return medicationCriteria.list();
}

16 Source : SearchWordByName.java
with GNU Affero General Public License v3.0
from KnowageLabs

@Override
public Criteria evaluate(Session session) {
    Criteria c = session.createCriteria(SbiGlWord.clreplaced);
    c.setProjection(Projections.projectionList().add(Projections.property("wordId"), "wordId").add(Projections.property("word"), "word")).setResultTransformer(Transformers.aliasToBean(SbiGlWord.clreplaced));
    if (word != null && !word.isEmpty()) {
        c.add(Restrictions.eq("word", word).ignoreCase());
    }
    return c;
}

16 Source : SearchContentsByName.java
with GNU Affero General Public License v3.0
from KnowageLabs

@Override
public Criteria evaluate(Session session) {
    Criteria c = session.createCriteria(SbiGlContents.clreplaced);
    c.setProjection(Projections.projectionList().add(Projections.property("contentId"), "contentId").add(Projections.property("contentNm"), "contentNm")).setResultTransformer(Transformers.aliasToBean(SbiGlContents.clreplaced));
    if (cont != null && !cont.isEmpty()) {
        c.add(Restrictions.eq("contentNm", cont).ignoreCase());
    }
    return c;
}

16 Source : SbiUserDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

/**
 * Get value of failed login attemtpts counter from DB.
 *
 * @author Marco Libanori
 */
@Override
public int getFailedLoginAttempts(String userId) {
    logger.debug("IN");
    Session aSession = null;
    Transaction tx = null;
    try {
        Integer result = 0;
        if (isUserIdAlreadyInUse(userId) != null) {
            aSession = getSession();
            tx = aSession.beginTransaction();
            ProjectionList projList = Projections.projectionList().add(Projections.property("failedLoginAttempts"), "failedLoginAttempts");
            SimpleExpression eq = Restrictions.eq("userId", userId);
            result = (Integer) aSession.createCriteria(SbiUser.clreplaced).add(eq).setProjection(projList).uniqueResult();
            tx.commit();
        }
        return result;
    } catch (HibernateException he) {
        if (tx != null)
            tx.rollback();
        throw new SpagoBIDAOException("Error while reading failed login attempts counter for user " + userId, he);
    } finally {
        logger.debug("OUT");
        if (aSession != null) {
            if (aSession.isOpen())
                aSession.close();
        }
    }
}

15 Source : PermissionDaoImpl.java
with GNU Lesser General Public License v2.1
from phoenixctms

@Override
protected Collection<Permission> handleFindByServiceMethodUser(String serviceMethod, Long userId, Boolean profilePermissionActive, Boolean userPermissionProfileActive) throws Exception {
    org.hibernate.Criteria permissionCritria = createPermissionCriteria();
    if (serviceMethod != null) {
        permissionCritria.add(Restrictions.eq("serviceMethod", serviceMethod));
    }
    if (userId != null || profilePermissionActive != null || userPermissionProfileActive != null) {
        org.hibernate.Criteria profilePermissionCritria = permissionCritria.createCriteria("profilePermissions", CriteriaSpecification.LEFT_JOIN);
        if (profilePermissionActive != null) {
            profilePermissionCritria.add(Restrictions.eq("active", profilePermissionActive.booleanValue()));
        }
        if (userId != null || userPermissionProfileActive != null) {
            // IMPL!!!!
            DetachedCriteria subQuery = DetachedCriteria.forClreplaced(UserPermissionProfileImpl.clreplaced, "userPermissionProfile");
            subQuery.setProjection(Projections.projectionList().add(Projections.property("profile")));
            if (userId != null) {
                subQuery.add(Restrictions.eq("user.id", userId.longValue()));
            }
            if (userPermissionProfileActive != null) {
                subQuery.add(Restrictions.eq("active", userPermissionProfileActive.booleanValue()));
            }
            profilePermissionCritria.add(Subqueries.propertyIn("profile", subQuery));
        }
    }
    return permissionCritria.list();
}

15 Source : DutyRosterTurnDaoImpl.java
with GNU Lesser General Public License v2.1
from phoenixctms

@Override
protected Collection<String> handleFindCalendars(Long trialDepartmentId, Long staffId, Long trialId, String calendarPrefix, Integer limit) throws Exception {
    Criteria dutyRosterCriteria = createDutyRosterTurnCriteria("dutyRosterTurn");
    Criteria trialCriteria = null;
    if (trialDepartmentId != null) {
        trialCriteria = dutyRosterCriteria.createCriteria("trial", CriteriaSpecification.LEFT_JOIN);
    } else if (trialId != null) {
        trialCriteria = dutyRosterCriteria.createCriteria("trial", CriteriaSpecification.INNER_JOIN);
    }
    if (trialDepartmentId != null || trialId != null) {
        if (trialDepartmentId != null) {
            trialCriteria.add(Restrictions.or(Restrictions.isNull("dutyRosterTurn.trial"), Restrictions.eq("department.id", trialDepartmentId.longValue())));
        }
        if (trialId != null) {
            trialCriteria.add(Restrictions.idEq(trialId.longValue()));
        }
    }
    if (staffId != null) {
        dutyRosterCriteria.add(Restrictions.eq("staff.id", staffId.longValue()));
    }
    CategoryCriterion.apply(dutyRosterCriteria, new CategoryCriterion(calendarPrefix, "calendar", MatchMode.START));
    dutyRosterCriteria.addOrder(Order.asc("calendar"));
    dutyRosterCriteria.setProjection(Projections.distinct(Projections.property("calendar")));
    CriteriaUtil.applyLimit(limit, Settings.getIntNullable(SettingCodes.DUTY_ROSTER_TURN_CALENDAR_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT, Bundle.SETTINGS, DefaultSettings.DUTY_ROSTER_TURN_CALENDAR_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT), dutyRosterCriteria);
    return dutyRosterCriteria.list();
}

15 Source : DutyRosterTurnDaoImpl.java
with GNU Lesser General Public License v2.1
from phoenixctms

@Override
protected Collection<String> handleFindreplacedles(Long trialDepartmentId, Long staffId, Long trialId, String replacedleInfix, Integer limit) throws Exception {
    Criteria dutyRosterCriteria = createDutyRosterTurnCriteria("dutyRosterTurn");
    Criteria trialCriteria = null;
    if (trialDepartmentId != null) {
        trialCriteria = dutyRosterCriteria.createCriteria("trial", CriteriaSpecification.LEFT_JOIN);
    } else if (trialId != null) {
        trialCriteria = dutyRosterCriteria.createCriteria("trial", CriteriaSpecification.INNER_JOIN);
    }
    if (trialDepartmentId != null || trialId != null) {
        if (trialDepartmentId != null) {
            trialCriteria.add(Restrictions.or(Restrictions.isNull("dutyRosterTurn.trial"), Restrictions.eq("department.id", trialDepartmentId.longValue())));
        }
        if (trialId != null) {
            trialCriteria.add(Restrictions.idEq(trialId.longValue()));
        }
    }
    if (staffId != null) {
        dutyRosterCriteria.add(Restrictions.eq("staff.id", staffId.longValue()));
    }
    CategoryCriterion.apply(dutyRosterCriteria, new CategoryCriterion(replacedleInfix, "replacedle", MatchMode.ANYWHERE));
    dutyRosterCriteria.addOrder(Order.asc("replacedle"));
    dutyRosterCriteria.setProjection(Projections.distinct(Projections.property("replacedle")));
    CriteriaUtil.applyLimit(limit, Settings.getIntNullable(SettingCodes.DUTY_ROSTER_TURN_replacedLE_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT, Bundle.SETTINGS, DefaultSettings.DUTY_ROSTER_TURN_replacedLE_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT), dutyRosterCriteria);
    return dutyRosterCriteria.list();
}

14 Source : InventoryBookingDaoImpl.java
with GNU Lesser General Public License v2.1
from phoenixctms

@Override
protected Collection<String> handleFindCalendars(Long inventoryDepartmentId, Long inventoryId, Long probandId, Long courseId, Long trialId, String calendarPrefix, Integer limit) throws Exception {
    Criteria bookingCriteria = createBookingCriteria();
    if (inventoryId != null) {
        bookingCriteria.add(Restrictions.eq("inventory.id", inventoryId.longValue()));
    }
    if (inventoryDepartmentId != null) {
        Criteria inventoryCriteria = bookingCriteria.createCriteria("inventory", CriteriaSpecification.INNER_JOIN);
        inventoryCriteria.add(Restrictions.eq("department.id", inventoryDepartmentId.longValue()));
    }
    if (probandId != null) {
        bookingCriteria.add(Restrictions.eq("proband.id", probandId.longValue()));
    }
    if (courseId != null) {
        bookingCriteria.add(Restrictions.eq("course.id", courseId.longValue()));
    }
    if (trialId != null) {
        bookingCriteria.add(Restrictions.eq("trial.id", trialId.longValue()));
    }
    CategoryCriterion.apply(bookingCriteria, new CategoryCriterion(calendarPrefix, "calendar", MatchMode.START));
    bookingCriteria.addOrder(Order.asc("calendar"));
    bookingCriteria.setProjection(Projections.distinct(Projections.property("calendar")));
    CriteriaUtil.applyLimit(limit, Settings.getIntNullable(SettingCodes.INVENTORY_BOOKING_CALENDAR_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT, Bundle.SETTINGS, DefaultSettings.INVENTORY_BOOKING_CALENDAR_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT), bookingCriteria);
    return bookingCriteria.list();
}

13 Source : HibernateVulnerabilitySearchDao.java
with Mozilla Public License 2.0
from secdec

private List<Integer> getVulnIdList(VulnerabilitySearchParameters parameters) {
    Criteria criteria = VulnerabilitySearchCriteriaConstructor.getCriteriaWithRestrictions(sessionFactory.getCurrentSession(), parameters);
    criteria.setProjection(Projections.projectionList().add(Projections.property("id")));
    List<Integer> idList = (List<Integer>) criteria.list();
    return idList;
}

13 Source : CriteriaUtil.java
with GNU Lesser General Public License v2.1
from phoenixctms

public static List listDistinctRootPSFVO(SubCriteriaMap criteriaMap, PSFVO psf, Object dao, String... distinctProjections) throws Exception {
    Criteria criteria;
    if (dao != null && criteriaMap != null && criteriaMap.getEnreplacedy() != null && (criteria = criteriaMap.getCriteria()) != null) {
        if (psf != null) {
            criteria.setProjection(null);
            criteria.setResultTransformer(CriteriaSpecification.ROOT_ENreplacedY);
            Method loadMethod = CoreUtil.getDaoLoadMethod(dao);
            replacedociationPath sortFieldreplacedociationPath = new replacedociationPath(psf.getSortField());
            Map<String, String> filters = psf.getFilters();
            if (filters != null && filters.size() > 0) {
                Iterator<Map.Entry<String, String>> filterIt = filters.entrySet().iterator();
                while (filterIt.hasNext()) {
                    Map.Entry<String, String> filter = filterIt.next();
                    replacedociationPath filterFieldreplacedociationPath = new replacedociationPath(filter.getKey());
                    Criteria subCriteria;
                    if (sortFieldreplacedociationPath.isValid() && sortFieldreplacedociationPath.getPathDepth() >= 1 && sortFieldreplacedociationPath.getPath().equals(filterFieldreplacedociationPath.getPath())) {
                        String alias = getProjectionAlias(sortFieldreplacedociationPath);
                        subCriteria = criteriaMap.createCriteriaForAttribute(filterFieldreplacedociationPath, alias);
                    } else {
                        subCriteria = criteriaMap.createCriteriaForAttribute(filterFieldreplacedociationPath);
                    }
                    subCriteria.add(applyFilter(filterFieldreplacedociationPath.getPropertyName(), criteriaMap.getPropertyClreplacedMap().get(filterFieldreplacedociationPath.getFullQualifiedPropertyName()), filter.getValue(), applyAlternativeFilter(criteriaMap, filterFieldreplacedociationPath, filter.getValue())));
                }
            }
            Long count = null;
            if (psf.getUpdateRowCount()) {
                Iterator it = criteria.setProjection(Projections.countDistinct("id")).list().iterator();
                if (it.hasNext()) {
                    count = (Long) it.next();
                }
                psf.setRowCount(count);
                criteria.setProjection(null);
                criteria.setResultTransformer(CriteriaSpecification.ROOT_ENreplacedY);
            }
            if (psf.getFirst() != null) {
                criteria.setFirstResult(psf.getFirst());
            }
            if (psf.getPageSize() != null) {
                count = psf.getPageSize().longValue();
                criteria.setMaxResults(CommonUtil.safeLongToInt(count));
            }
            ProjectionList projectionList = Projections.projectionList().add(Projections.id());
            boolean cast = false;
            Criteria projectioncriteria = getProjectionCriteria(criteriaMap, sortFieldreplacedociationPath);
            if (projectioncriteria != null) {
                projectioncriteria.addOrder(psf.getSortOrder() ? Order.asc(sortFieldreplacedociationPath.getPropertyName()) : Order.desc(sortFieldreplacedociationPath.getPropertyName()));
                projectionList.add(Projections.property(sortFieldreplacedociationPath.getFullQualifiedPropertyName()));
                cast = true;
            }
            if (distinctProjections != null && distinctProjections.length > 0) {
                for (int i = 0; i < distinctProjections.length; i++) {
                    replacedociationPath distinctProjectionreplacedociationPath = new replacedociationPath(distinctProjections[i]);
                    projectioncriteria = getProjectionCriteria(criteriaMap, distinctProjectionreplacedociationPath);
                    if (projectioncriteria != null) {
                        projectionList.add(Projections.property(distinctProjectionreplacedociationPath.getFullQualifiedPropertyName()));
                        cast = true;
                    }
                }
            }
            Iterator it = criteria.setProjection(Projections.distinct(projectionList)).list().iterator();
            ArrayList result = (count == null ? new ArrayList() : new ArrayList(CommonUtil.safeLongToInt(count)));
            while (it.hasNext()) {
                result.add(loadMethod.invoke(dao, cast ? ((Object[]) it.next())[0] : it.next()));
            }
            return result;
        } else {
            return listDistinctRoot(criteria, dao);
        }
    }
    return null;
}

13 Source : SearchWord.java
with GNU Affero General Public License v3.0
from KnowageLabs

@Override
public Criteria evaluate(Session session) {
    Criteria c = session.createCriteria(SbiGlWord.clreplaced);
    c.addOrder(Order.asc("word"));
    c.setProjection(Projections.projectionList().add(Projections.property("wordId"), "wordId").add(Projections.property("word"), "word")).setResultTransformer(Transformers.aliasToBean(SbiGlWord.clreplaced));
    if (page != null && item_per_page != null) {
        c.setFirstResult((page - 1) * item_per_page);
        c.setMaxResults(item_per_page);
    }
    return c;
}

12 Source : InputFieldValueDaoImpl.java
with GNU Lesser General Public License v2.1
from phoenixctms

/**
 * @inheritDoc
 */
@Override
protected Collection<String> handleFindTextValues(String textValueInfix, Integer limit) {
    org.hibernate.Criteria inputFieldValueCriteria = createInputFieldValueCriteria();
    CategoryCriterion.apply(inputFieldValueCriteria, new CategoryCriterion(textValueInfix, "truncatedStringValue", MatchMode.ANYWHERE));
    inputFieldValueCriteria.addOrder(Order.asc("truncatedStringValue"));
    inputFieldValueCriteria.setProjection(Projections.distinct(Projections.property("truncatedStringValue")));
    CriteriaUtil.applyLimit(limit, Settings.getIntNullable(SettingCodes.INPUT_FIELD_TEXT_VALUE_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT, Bundle.SETTINGS, DefaultSettings.INPUT_FIELD_TEXT_VALUE_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT), inputFieldValueCriteria);
    return inputFieldValueCriteria.list();
}

12 Source : AllVersionsWhereClause.java
with Apache License 2.0
from openequella

@Override
public void addWhere(ItemSerializerState state) {
    ProjectionList projections = state.gereplacedemProjection();
    DetachedCriteria criteria = state.gereplacedemQuery();
    criteria.add(Restrictions.eq("uuid", uuid));
    criteria.addOrder(Order.asc(PROPERTY_VERSION));
    projections.add(Projections.property(PROPERTY_VERSION), ALIAS_VERSION);
}

11 Source : BasicItemSerializerProvider.java
with Apache License 2.0
from openequella

@Override
public void prepareItemQuery(ItemSerializerState state) {
    final DetachedCriteria criteria = state.gereplacedemQuery();
    final ProjectionList projection = state.gereplacedemProjection();
    if (state.hasCategory(ItemSerializerService.CATEGORY_BASIC)) {
        projection.add(Projections.property("name.id"), NAME_ALIAS);
        projection.add(Projections.property("description.id"), DESC_ALIAS);
    }
    if (state.hasCategory(ItemSerializerService.CATEGORY_METADATA)) {
        criteria.createAlias("itemXml", "itemXml");
        projection.add(Projections.property("itemXml.xml"), METADATA_ALIAS);
    }
}

10 Source : VulnerabilitySearchCriteriaConstructor.java
with Mozilla Public License 2.0
from secdec

private void addAppTags() {
    List<Integer> appIds;
    List<Integer> tagIds = list();
    if (parameters.getTags() != null) {
        for (Tag tag : parameters.getTags()) {
            if (tag.getId() != null) {
                tagIds.add(tag.getId());
            }
        }
    }
    if (tagIds.isEmpty()) {
        LOG.debug("No tag IDs found in parameters.");
    } else {
        Criteria subCriteria = session.createCriteria(Tag.clreplaced);
        subCriteria.createAlias("applications", "applicationsAlias");
        subCriteria.add(Restrictions.in("id", tagIds));
        subCriteria.setProjection(Projections.property("applicationsAlias.id"));
        appIds = (List<Integer>) subCriteria.list();
        if (appIds.isEmpty())
            appIds.add(0);
        criteria.add(Restrictions.in("application.id", appIds));
        LOG.debug("Added applications with IDs " + appIds);
    }
}

10 Source : VulnerabilitySearchCriteriaConstructor.java
with Mozilla Public License 2.0
from secdec

private void addChannelTypeRestrictions() {
    // Limit scanner if present
    if (parameters.getChannelTypes() != null && !parameters.getChannelTypes().isEmpty()) {
        List<Integer> channelTypeIds = list();
        for (ChannelType channelType : parameters.getChannelTypes()) {
            if (channelType.getId() != null) {
                channelTypeIds.add(channelType.getId());
            }
        }
        if (!channelTypeIds.isEmpty()) {
            Criteria subCriteria = session.createCriteria(Finding.clreplaced);
            subCriteria.createAlias("scan", "myScan");
            subCriteria.createAlias("myScan.applicationChannel", "myApplicationChannel");
            subCriteria.createAlias("myApplicationChannel.channelType", "myChannelType");
            subCriteria.add(Restrictions.in("myChannelType.id", channelTypeIds));
            subCriteria.setProjection(Projections.property("vulnerability.id"));
            List<Integer> ids = (List<Integer>) subCriteria.list();
            if (ids.isEmpty()) {
                LOG.debug("Got no valid Scanner type IDs.");
                // should yield no results
                ids.add(0);
            // throw an exception here?
            } else {
                LOG.debug("Adding scanner restriction: " + channelTypeIds);
            }
            criteria.add(Restrictions.in("id", ids));
        }
    }
}

10 Source : StreetDaoImpl.java
with GNU Lesser General Public License v2.1
from phoenixctms

@Override
protected Collection<String> handleFindStreetNames(String countryName, String zipCode, String cityName, String streetNameInfix, Integer limit) throws Exception {
    org.hibernate.Criteria streetCriteria = createStreetCriteria();
    applyStreetCriterions(streetCriteria, countryName, zipCode, cityName, streetNameInfix);
    streetCriteria.add(Restrictions.not(Restrictions.or(Restrictions.eq("streetName", ""), Restrictions.isNull("streetName"))));
    streetCriteria.addOrder(Order.asc("streetName"));
    streetCriteria.setProjection(Projections.distinct(Projections.property("streetName")));
    CriteriaUtil.applyLimit(limit, Settings.getIntNullable(SettingCodes.STREET_NAME_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT, Bundle.SETTINGS, DefaultSettings.STREET_NAME_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT), streetCriteria);
    return streetCriteria.list();
}

10 Source : BankIdentificationDaoImpl.java
with GNU Lesser General Public License v2.1
from phoenixctms

/**
 * @inheritDoc
 */
@Override
protected Collection<String> handleFindBankCodeNumbers(String bankCodeNumberPrefix, String bicPrefix, String bankNameInfix, Integer limit) {
    org.hibernate.Criteria bankIdentificationCriteria = createBankIdentificationCriteria();
    applyBankIdentificationCriterions(bankIdentificationCriteria, bankCodeNumberPrefix, bicPrefix, bankNameInfix);
    bankIdentificationCriteria.add(Restrictions.not(Restrictions.or(Restrictions.eq("bankCodeNumber", ""), Restrictions.isNull("bankCodeNumber"))));
    bankIdentificationCriteria.addOrder(Order.asc("bankCodeNumber"));
    bankIdentificationCriteria.setProjection(Projections.distinct(Projections.property("bankCodeNumber")));
    CriteriaUtil.applyLimit(limit, Settings.getIntNullable(SettingCodes.BANK_CODE_NUMBER_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT, Bundle.SETTINGS, DefaultSettings.BANK_CODE_NUMBER_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT), bankIdentificationCriteria);
    return bankIdentificationCriteria.list();
}

10 Source : DetailsItemSerializerProvider.java
with Apache License 2.0
from openequella

@Override
public void prepareItemQuery(ItemSerializerState state) {
    if (state.hasCategory(CATEGORY_DETAIL)) {
        final ProjectionList projection = state.gereplacedemProjection();
        state.addOwnerQuery();
        state.addStatusQuery();
        state.addCollectionQuery();
        projection.add(Projections.property(CREATED_PROPERTY), CREATED_PROPERTY);
        projection.add(Projections.property(MODIFIED_PROPERTY), MODIFIED_PROPERTY);
        projection.add(Projections.property(RATING_PROPERTY), RATING_PROPERTY);
        projection.add(Projections.property(THUMBNAIL_PROPERTY), THUMBNAIL_PROPERTY);
    }
}

10 Source : SearchGlossaryByName.java
with GNU Affero General Public License v3.0
from KnowageLabs

@Override
public Criteria evaluate(Session session) {
    Criteria criteria = session.createCriteria(SbiGlGlossary.clreplaced);
    criteria.setProjection(Projections.projectionList().add(Projections.property("glossaryId"), "glossaryId").add(Projections.property("glossaryNm"), "glossaryNm")).setResultTransformer(Transformers.aliasToBean(SbiGlGlossary.clreplaced));
    if (glossary != null && !glossary.isEmpty()) {
        criteria.add(Restrictions.like("glossaryNm", glossary, MatchMode.ANYWHERE).ignoreCase());
    }
    if (page != null && itemsPerPage != null) {
        criteria.setFirstResult((page - 1) * itemsPerPage);
        criteria.setMaxResults(itemsPerPage);
    }
    return criteria;
}

9 Source : OperationalDataRecordManager.java
with MIT License
from ria-ee

private static void setProjectionList(Criteria criteria, Set<String> fields) {
    ProjectionList projList = Projections.projectionList();
    HashSet<String> fieldSet = new HashSet<>(fields);
    // Necessary for searching the records.
    fieldSet.add(MONITORING_DATA_TS);
    log.trace("setProjectionList(): {}", fieldSet);
    fieldSet.forEach(i -> projList.add(Projections.property(i), i));
    criteria.setProjection(projList);
    criteria.setResultTransformer(Transformers.aliasToBean(OperationalDataRecord.clreplaced));
}

9 Source : ZipDaoImpl.java
with GNU Lesser General Public License v2.1
from phoenixctms

@Override
protected Collection<String> handleFindZipCodes(String countryNameInfix, String zipCodePrefix, String cityNameInfix, Integer limit) throws Exception {
    org.hibernate.Criteria zipCriteria = createZipCriteria();
    applyZipCriterions(zipCriteria, countryNameInfix, zipCodePrefix, cityNameInfix);
    zipCriteria.add(Restrictions.not(Restrictions.or(Restrictions.eq("zipCode", ""), Restrictions.isNull("zipCode"))));
    zipCriteria.addOrder(Order.asc("zipCode"));
    zipCriteria.setProjection(Projections.distinct(Projections.property("zipCode")));
    CriteriaUtil.applyLimit(limit, Settings.getIntNullable(SettingCodes.ZIP_CODE_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT, Bundle.SETTINGS, DefaultSettings.ZIP_CODE_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT), zipCriteria);
    return zipCriteria.list();
}

9 Source : ZipDaoImpl.java
with GNU Lesser General Public License v2.1
from phoenixctms

@Override
protected Collection<String> handleFindCityNames(String countryNameInfix, String zipCodePrefix, String cityNameInfix, Integer limit) throws Exception {
    org.hibernate.Criteria zipCriteria = createZipCriteria();
    applyZipCriterions(zipCriteria, countryNameInfix, zipCodePrefix, cityNameInfix);
    zipCriteria.add(Restrictions.not(Restrictions.or(Restrictions.eq("cityName", ""), Restrictions.isNull("cityName"))));
    zipCriteria.addOrder(Order.asc("cityName"));
    zipCriteria.setProjection(Projections.distinct(Projections.property("cityName")));
    CriteriaUtil.applyLimit(limit, Settings.getIntNullable(SettingCodes.CITY_NAME_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT, Bundle.SETTINGS, DefaultSettings.CITY_NAME_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT), zipCriteria);
    return zipCriteria.list();
}

9 Source : TitleDaoImpl.java
with GNU Lesser General Public License v2.1
from phoenixctms

@Override
protected Collection<String> handleFindreplacedles(String replacedlePrefix, Integer limit) throws Exception {
    org.hibernate.Criteria replacedleCriteria = this.getSession().createCriteria(replacedle.clreplaced);
    replacedleCriteria.setCacheable(true);
    CategoryCriterion.apply(replacedleCriteria, new CategoryCriterion(replacedlePrefix, "replacedle", MatchMode.START));
    replacedleCriteria.add(Restrictions.not(Restrictions.or(Restrictions.eq("replacedle", ""), Restrictions.isNull("replacedle"))));
    replacedleCriteria.addOrder(Order.asc("replacedle"));
    replacedleCriteria.setProjection(Projections.distinct(Projections.property("replacedle")));
    CriteriaUtil.applyLimit(limit, Settings.getIntNullable(SettingCodes.replacedLE_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT, Bundle.SETTINGS, DefaultSettings.replacedLE_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT), replacedleCriteria);
    return replacedleCriteria.list();
}

9 Source : OpsSystBlockDaoImpl.java
with GNU Lesser General Public License v2.1
from phoenixctms

@Override
protected Collection<String> handleFindBlockPreferredRubricLabels(String preferredRubricLabelInfix, Integer limit) throws Exception {
    org.hibernate.Criteria opsSystBlockCriteria = this.getSession().createCriteria(OpsSystBlock.clreplaced);
    opsSystBlockCriteria.setCacheable(true);
    CategoryCriterion.apply(opsSystBlockCriteria, new CategoryCriterion(preferredRubricLabelInfix, "preferredRubricLabel", MatchMode.ANYWHERE));
    opsSystBlockCriteria.add(Restrictions.not(Restrictions.or(Restrictions.eq("preferredRubricLabel", ""), Restrictions.isNull("preferredRubricLabel"))));
    opsSystBlockCriteria.addOrder(Order.asc("preferredRubricLabel"));
    opsSystBlockCriteria.setProjection(Projections.distinct(Projections.property("preferredRubricLabel")));
    CriteriaUtil.applyLimit(limit, Settings.getIntNullable(SettingCodes.OPS_SYST_BLOCK_PREFERRED_RUBRIC_LABEL_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT, Bundle.SETTINGS, DefaultSettings.OPS_SYST_BLOCK_PREFERRED_RUBRIC_LABEL_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT), opsSystBlockCriteria);
    return opsSystBlockCriteria.list();
}

9 Source : InputFieldSelectionSetValueDaoImpl.java
with GNU Lesser General Public License v2.1
from phoenixctms

@Override
protected Collection<String> handleFindValues(Long fieldId, String valueInfix, Integer limit) throws Exception {
    org.hibernate.Criteria selectionSetValueCriteria = createSelectionSetValueCriteria();
    if (fieldId != null) {
        selectionSetValueCriteria.add(Restrictions.eq("field.id", fieldId.longValue()));
    }
    CategoryCriterion.apply(selectionSetValueCriteria, new CategoryCriterion(valueInfix, "value", MatchMode.ANYWHERE));
    selectionSetValueCriteria.addOrder(Order.asc("value"));
    selectionSetValueCriteria.setProjection(Projections.distinct(Projections.property("value")));
    CriteriaUtil.applyLimit(limit, Settings.getIntNullable(SettingCodes.INPUT_FIELD_SELECTION_SET_VALUE_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT, Bundle.SETTINGS, DefaultSettings.INPUT_FIELD_SELECTION_SET_VALUE_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT), selectionSetValueCriteria);
    return selectionSetValueCriteria.list();
}

9 Source : CriteriaDaoImpl.java
with GNU Lesser General Public License v2.1
from phoenixctms

@Override
protected Collection<String> handleFindCategories(DBModule module, String categoryPrefix, Integer limit) throws Exception {
    org.hibernate.Criteria criteriaCriteria = createCriteriaCriteria();
    if (module != null) {
        criteriaCriteria.add(Restrictions.eq("module", module));
    }
    CategoryCriterion.apply(criteriaCriteria, new CategoryCriterion(categoryPrefix, "category", MatchMode.START));
    criteriaCriteria.addOrder(Order.asc("category"));
    criteriaCriteria.setProjection(Projections.distinct(Projections.property("category")));
    CriteriaUtil.applyLimit(limit, Settings.getIntNullable(SettingCodes.CRITERIA_CATEGORY_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT, Bundle.SETTINGS, DefaultSettings.CRITERIA_CATEGORY_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT), criteriaCriteria);
    return criteriaCriteria.list();
}

9 Source : BankIdentificationDaoImpl.java
with GNU Lesser General Public License v2.1
from phoenixctms

/**
 * @inheritDoc
 */
@Override
protected Collection<String> handleFindBankNames(String bankCodeNumberPrefix, String bicPrefix, String bankNameInfix, Integer limit) {
    org.hibernate.Criteria bankIdentificationCriteria = createBankIdentificationCriteria();
    applyBankIdentificationCriterions(bankIdentificationCriteria, bankCodeNumberPrefix, bicPrefix, bankNameInfix);
    bankIdentificationCriteria.add(Restrictions.not(Restrictions.or(Restrictions.eq("bankName", ""), Restrictions.isNull("bankName"))));
    bankIdentificationCriteria.addOrder(Order.asc("bankName"));
    bankIdentificationCriteria.setProjection(Projections.distinct(Projections.property("bankName")));
    CriteriaUtil.applyLimit(limit, Settings.getIntNullable(SettingCodes.BANK_NAME_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT, Bundle.SETTINGS, DefaultSettings.BANK_NAME_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT), bankIdentificationCriteria);
    return bankIdentificationCriteria.list();
}

9 Source : BankIdentificationDaoImpl.java
with GNU Lesser General Public License v2.1
from phoenixctms

/**
 * @inheritDoc
 */
@Override
protected Collection<String> handleFindBics(String bankCodeNumberPrefix, String bicPrefix, String bankNameInfix, Integer limit) {
    org.hibernate.Criteria bankIdentificationCriteria = createBankIdentificationCriteria();
    applyBankIdentificationCriterions(bankIdentificationCriteria, bankCodeNumberPrefix, bicPrefix, bankNameInfix);
    bankIdentificationCriteria.add(Restrictions.not(Restrictions.or(Restrictions.eq("bic", ""), Restrictions.isNull("bic"))));
    bankIdentificationCriteria.addOrder(Order.asc("bic"));
    bankIdentificationCriteria.setProjection(Projections.distinct(Projections.property("bic")));
    CriteriaUtil.applyLimit(limit, Settings.getIntNullable(SettingCodes.BIC_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT, Bundle.SETTINGS, DefaultSettings.BIC_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT), bankIdentificationCriteria);
    return bankIdentificationCriteria.list();
}

8 Source : DaoUtil.java
with Apache License 2.0
from tmobile

public static List<ApiStatus> getEnvApis(String startDate, String endDate, int envId, String componentIdsStrg, Session session, Clreplaced enireplacedyClreplaced) throws ParseException {
    final SimpleDateFormat sdf = new SimpleDateFormat(SIMPLE_DATE_FORMAT);
    List<Integer> comIdList = DaoUtil.convertCSVToList(componentIdsStrg);
    Date sDate = sdf.parse(startDate);
    Date eDate = sdf.parse(endDate);
    Criteria apiCriteria = session.createCriteria(enireplacedyClreplaced, "apiSts");
    apiCriteria.createCriteria("apiSts.component", "component");
    apiCriteria.createCriteria("apiSts.environment", "environment");
    apiCriteria.add(Restrictions.gt("apiSts.statusDate", sDate));
    apiCriteria.add(Restrictions.le("apiSts.statusDate", eDate));
    if (envId != 0) {
        apiCriteria.add(Restrictions.eq("environment.environmentId", envId));
    }
    if (comIdList.size() > 0) {
        apiCriteria.add(Restrictions.in("component.componentId", comIdList));
    }
    apiCriteria.add(Restrictions.eq("environment.envLock", 0));
    ProjectionList projectionList = Projections.projectionList();
    projectionList.add(Projections.property("component.componentId"));
    projectionList.add(Projections.property("apiSts.statusDate"));
    projectionList.add(Projections.property("component.componentName"));
    projectionList.add(Projections.sum("apiSts.totalApi"));
    projectionList.add(Projections.groupProperty("component.componentId"));
    projectionList.add(Projections.groupProperty("apiSts.statusDate"));
    apiCriteria.setProjection(projectionList);
    @SuppressWarnings("unchecked")
    List<Object[]> appList = apiCriteria.list();
    List<ApiStatus> apiStatusList = new ArrayList<ApiStatus>();
    for (Object[] aRow : appList) {
        ApiStatus apisStatus = new ApiStatus();
        Integer comId = (Integer) aRow[0];
        apisStatus.setComponentId(comId);
        Date statsDate = (Date) aRow[1];
        apisStatus.setStatusDate(statsDate.toString());
        String compName = (String) aRow[2];
        apisStatus.setComponentName(compName);
        long totalApi = (long) aRow[3];
        apisStatus.setTotalApis(totalApi);
        apiStatusList.add(apisStatus);
    }
    session.close();
    return apiStatusList;
}

See More Examples