Example usage for org.hibernate Criteria addOrder

List of usage examples for org.hibernate Criteria addOrder

Introduction

In this page you can find the example usage for org.hibernate Criteria addOrder.

Prototype

public Criteria addOrder(Order order);

Source Link

Document

Add an Order ordering to the result set.

Usage

From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java

License:Open Source License

public List<PickedPhenoDataSetCategory> getPickedPhenoDataSetCategories(Study study, ArkFunction arkFunction,
        ArkUser arkUser) {/*from ww  w.  j a v a2 s . co m*/
    Criteria criteria = getSession().createCriteria(PickedPhenoDataSetCategory.class);
    criteria.add(Restrictions.eq("study", study));
    criteria.add(Restrictions.eq("arkFunction", arkFunction));
    criteria.add(Restrictions.eq("arkUser", arkUser));
    criteria.addOrder(Order.asc("orderNumber"));
    return (List<PickedPhenoDataSetCategory>) criteria.list();
}

From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java

License:Open Source License

@Override
public List<PhenoDataSetField> getLinkedPhenoDataSetFieldsForSelectedCategories(Study study,
        ArkFunction arkFunction, ArkUser arkUser, List<PhenoDataSetCategory> phenoDataSetCategories) {
    List<LinkPhenoDataSetCategoryField> linkPhenoDataSetCategoryFields = new ArrayList<LinkPhenoDataSetCategoryField>();
    List<PhenoDataSetField> sumofPhenoDataSetFields = new ArrayList<PhenoDataSetField>();
    for (PhenoDataSetCategory phenoDataSetCategory : phenoDataSetCategories) {
        Criteria criteria = getSession().createCriteria(LinkPhenoDataSetCategoryField.class);
        criteria.add(Restrictions.eq("study", study));
        criteria.add(Restrictions.eq("arkFunction", arkFunction));
        criteria.add(Restrictions.eq("arkUser", arkUser));
        criteria.add(Restrictions.eq("phenoDataSetCategory", phenoDataSetCategory));
        criteria.addOrder(Order.asc("orderNumber"));
        linkPhenoDataSetCategoryFields = (List<LinkPhenoDataSetCategoryField>) criteria.list();
        for (LinkPhenoDataSetCategoryField linkPhenoDataSetCategoryField : linkPhenoDataSetCategoryFields) {
            sumofPhenoDataSetFields.add(linkPhenoDataSetCategoryField.getPhenoDataSetField());
        }/*from ww  w.j  av a 2 s  .c om*/
        linkPhenoDataSetCategoryFields.clear();
    }
    return sumofPhenoDataSetFields;

}

From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java

License:Open Source License

@Override
public PickedPhenoDataSetCategory getSwapOverPickedPhenoDataSetCategoryForUpButton(
        PickedPhenoDataSetCategory pickedPhenoDataSetCategory) {
    Criteria criteria = getSession().createCriteria(PickedPhenoDataSetCategory.class);
    criteria.add(Restrictions.eq("arkFunction", pickedPhenoDataSetCategory.getArkFunction()));
    criteria.add(Restrictions.eq("study", pickedPhenoDataSetCategory.getStudy()));
    criteria.add(Restrictions.eq("arkUser", pickedPhenoDataSetCategory.getArkUser()));
    if (pickedPhenoDataSetCategory.getParentPickedPhenoDataSetCategory() != null) {
        criteria.add(Restrictions.eq("parentPickedPhenoDataSetCategory",
                pickedPhenoDataSetCategory.getParentPickedPhenoDataSetCategory()));
    } else {/* w ww . j  av a2s  .  c o  m*/
        criteria.add(Restrictions.isNull("parentPickedPhenoDataSetCategory"));
    }
    criteria.add(Restrictions.lt("orderNumber", pickedPhenoDataSetCategory.getOrderNumber()));
    criteria.addOrder(Order.desc("orderNumber"));
    criteria.setFirstResult(0);
    criteria.setMaxResults(1);
    List<PickedPhenoDataSetCategory> pickedPhenoDataSetCategories = (List<PickedPhenoDataSetCategory>) criteria
            .list();
    if (pickedPhenoDataSetCategories.size() > 0) {
        return pickedPhenoDataSetCategories.get(0);
    } else {
        return null;
    }
}

From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java

License:Open Source License

@Override
public PickedPhenoDataSetCategory getSwapOverPickedPhenoDataSetCategoryForDownButton(
        PickedPhenoDataSetCategory pickedPhenoDataSetCategory) {
    Criteria criteria = getSession().createCriteria(PickedPhenoDataSetCategory.class);
    criteria.add(Restrictions.eq("arkFunction", pickedPhenoDataSetCategory.getArkFunction()));
    criteria.add(Restrictions.eq("study", pickedPhenoDataSetCategory.getStudy()));
    criteria.add(Restrictions.eq("arkUser", pickedPhenoDataSetCategory.getArkUser()));
    if (pickedPhenoDataSetCategory.getParentPickedPhenoDataSetCategory() != null) {
        criteria.add(Restrictions.eq("parentPickedPhenoDataSetCategory",
                pickedPhenoDataSetCategory.getParentPickedPhenoDataSetCategory()));
    } else {/*w  w  w  . j  a  va 2s .  co  m*/
        criteria.add(Restrictions.isNull("parentPickedPhenoDataSetCategory"));
    }
    criteria.add(Restrictions.gt("orderNumber", pickedPhenoDataSetCategory.getOrderNumber()));
    criteria.addOrder(Order.asc("orderNumber"));
    criteria.setFirstResult(0);
    criteria.setMaxResults(1);
    List<PickedPhenoDataSetCategory> pickedPhenoDataSetCategories = (List<PickedPhenoDataSetCategory>) criteria
            .list();
    if (pickedPhenoDataSetCategories.size() > 0) {
        return pickedPhenoDataSetCategories.get(0);
    } else {
        return null;
    }
}

From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java

License:Open Source License

@Override
public LinkPhenoDataSetCategoryField getSwapOverPhenoDataSetFieldForUpButton(
        LinkPhenoDataSetCategoryField linkPhenoDataSetCategoryField) {
    Criteria criteria = getSession().createCriteria(LinkPhenoDataSetCategoryField.class);
    criteria.add(Restrictions.eq("arkFunction", linkPhenoDataSetCategoryField.getArkFunction()));
    criteria.add(Restrictions.eq("study", linkPhenoDataSetCategoryField.getStudy()));
    criteria.add(Restrictions.eq("arkUser", linkPhenoDataSetCategoryField.getArkUser()));
    criteria.add(/*from  w ww. j a v a 2s .  co m*/
            Restrictions.eq("phenoDataSetCategory", linkPhenoDataSetCategoryField.getPhenoDataSetCategory()));
    criteria.add(Restrictions.lt("orderNumber", linkPhenoDataSetCategoryField.getOrderNumber()));
    criteria.addOrder(Order.desc("orderNumber"));
    criteria.setFirstResult(0);
    criteria.setMaxResults(1);
    List<LinkPhenoDataSetCategoryField> linkPhenoDataSetCategoryFields = (List<LinkPhenoDataSetCategoryField>) criteria
            .list();
    if (linkPhenoDataSetCategoryFields.size() > 0) {
        return linkPhenoDataSetCategoryFields.get(0);
    } else {
        return null;
    }
}

From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java

License:Open Source License

@Override
public LinkPhenoDataSetCategoryField getSwapOverPhenoDataSetFieldForDownButton(
        LinkPhenoDataSetCategoryField linkPhenoDataSetCategoryField) {
    Criteria criteria = getSession().createCriteria(LinkPhenoDataSetCategoryField.class);
    criteria.add(Restrictions.eq("arkFunction", linkPhenoDataSetCategoryField.getArkFunction()));
    criteria.add(Restrictions.eq("study", linkPhenoDataSetCategoryField.getStudy()));
    criteria.add(Restrictions.eq("arkUser", linkPhenoDataSetCategoryField.getArkUser()));
    criteria.add(/*from ww w  .  j a  va  2 s .  c  o m*/
            Restrictions.eq("phenoDataSetCategory", linkPhenoDataSetCategoryField.getPhenoDataSetCategory()));
    criteria.add(Restrictions.gt("orderNumber", linkPhenoDataSetCategoryField.getOrderNumber()));
    criteria.addOrder(Order.asc("orderNumber"));
    criteria.setFirstResult(0);
    criteria.setMaxResults(1);
    List<LinkPhenoDataSetCategoryField> linkPhenoDataSetCategoryFields = (List<LinkPhenoDataSetCategoryField>) criteria
            .list();
    if (linkPhenoDataSetCategoryFields.size() > 0) {
        return linkPhenoDataSetCategoryFields.get(0);
    } else {
        return null;
    }
}

From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java

License:Open Source License

@Override
public List<PickedPhenoDataSetCategory> getChildrenOfPickedPhenoDataSetCategory(
        PickedPhenoDataSetCategory pickedPhenoDataSetCategory) {
    Criteria criteria = getSession().createCriteria(PickedPhenoDataSetCategory.class);
    criteria.add(Restrictions.eq("arkFunction", pickedPhenoDataSetCategory.getArkFunction()));
    criteria.add(Restrictions.eq("study", pickedPhenoDataSetCategory.getStudy()));
    criteria.add(Restrictions.eq("arkUser", pickedPhenoDataSetCategory.getArkUser()));
    criteria.add(Restrictions.eq("parentPickedPhenoDataSetCategory", pickedPhenoDataSetCategory));
    criteria.addOrder(Order.asc("orderNumber"));
    return (List<PickedPhenoDataSetCategory>) criteria.list();
}

From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java

License:Open Source License

@Override
public List<PickedPhenoDataSetCategory> getAllParentPickedPhenoDataSetCategories(Study study,
        ArkFunction arkFunction, ArkUser arkUser) {
    Criteria criteria = getSession().createCriteria(PickedPhenoDataSetCategory.class);
    criteria.add(Restrictions.eq("arkFunction", arkFunction));
    criteria.add(Restrictions.eq("study", study));
    criteria.add(Restrictions.eq("arkUser", arkUser));
    criteria.add(Restrictions.isNull("parentPickedPhenoDataSetCategory"));
    criteria.addOrder(Order.asc("orderNumber"));
    return (List<PickedPhenoDataSetCategory>) criteria.list();
}

From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java

License:Open Source License

@Override
public List<LinkPhenoDataSetCategoryField> getLinkPhenoDataSetCategoryFieldsForPickedPhenoDataSetCategory(
        PickedPhenoDataSetCategory pickedPhenoDataSetCategory) {
    Criteria criteria = getSession().createCriteria(LinkPhenoDataSetCategoryField.class);
    criteria.add(Restrictions.eq("study", pickedPhenoDataSetCategory.getStudy()));
    criteria.add(Restrictions.eq("arkFunction", pickedPhenoDataSetCategory.getArkFunction()));
    criteria.add(Restrictions.eq("arkUser", pickedPhenoDataSetCategory.getArkUser()));
    criteria.add(Restrictions.eq("phenoDataSetCategory", pickedPhenoDataSetCategory.getPhenoDataSetCategory()));
    criteria.addOrder(Order.asc("orderNumber"));
    return (List<LinkPhenoDataSetCategoryField>) criteria.list();
}

From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java

License:Open Source License

/**
 * This return both categories and the fields of phenodatasetfieldsDisplay tables.
 * Note:Not only the fields.          //  ww w .  j  a  va 2s.  co m
 */
@Override
public List<PhenoDataSetFieldDisplay> getPhenoDataSetFieldDisplayForPhenoDataSetFieldGroup(
        PhenoDataSetGroup phenoDataSetGroup) {
    Criteria criteria = getSession().createCriteria(PhenoDataSetFieldDisplay.class);
    criteria.add(Restrictions.eq("phenoDataSetGroup", phenoDataSetGroup));
    //Ordering first from the category and then from the field
    criteria.addOrder(Order.asc("phenoDataSetCategoryOrderNumber"))
            .addOrder(Order.asc("phenoDataSetFiledOrderNumber"));
    return criteria.list();
}