Example usage for org.hibernate.criterion Restrictions and

List of usage examples for org.hibernate.criterion Restrictions and

Introduction

In this page you can find the example usage for org.hibernate.criterion Restrictions and.

Prototype

public static LogicalExpression and(Criterion lhs, Criterion rhs) 

Source Link

Document

Return the conjuction of two expressions

Usage

From source file:org.dspace.eperson.dao.impl.EPersonDAOImpl.java

License:BSD License

@Override
public List<EPerson> findWithPasswordWithoutDigestAlgorithm(Context context) throws SQLException {
    Criteria criteria = createCriteria(context, EPerson.class);
    criteria.add(Restrictions.and(Restrictions.isNotNull("password"), Restrictions.isNull("digestAlgorithm")));
    return list(criteria);
}

From source file:org.dspace.eperson.dao.impl.SubscriptionDAOImpl.java

License:BSD License

@Override
public Subscription findByCollectionAndEPerson(Context context, EPerson eperson, Collection collection)
        throws SQLException {
    Criteria criteria = createCriteria(context, Subscription.class);
    criteria.add(//w w  w. j  a va 2s.c  om
            Restrictions.and(Restrictions.eq("ePerson", eperson), Restrictions.eq("collection", collection)));
    return singleResult(criteria);
}

From source file:org.dspace.harvest.dao.impl.HarvestedCollectionDAOImpl.java

License:BSD License

@Override
public List<HarvestedCollection> findByLastHarvestedAndHarvestTypeAndHarvestStatusesAndHarvestTime(
        Context context, Date startTime, int minimalType, int[] statuses, int expirationStatus,
        Date expirationTime) throws SQLException {
    //      Old query: "SELECT * FROM harvested_collection WHERE
    // (last_harvested < ? or last_harvested is null) and harvest_type > ? and (harvest_status = ? or harvest_status = ? or (harvest_status=? and harvest_start_time < ?)) ORDER BY last_harvested",
    //                new java.sql.Timestamp(startTime.getTime()), 0, HarvestedCollection.STATUS_READY, HarvestedCollection.STATUS_OAI_ERROR, HarvestedCollection.STATUS_BUSY, new java.sql.Timestamp(expirationTime.getTime()));
    Criteria criteria = createCriteria(context, HarvestedCollection.class);
    LogicalExpression lastHarvestedRestriction = Restrictions.or(Restrictions.lt("lastHarvested", startTime),
            Restrictions.isNull("lastHarvested"));
    Disjunction statusRestriction = Restrictions.or();
    for (int status : statuses) {
        statusRestriction.add(Restrictions.eq("harvestStatus", status));
    }/*from   w  w w.  j  a  v a2  s.c om*/
    statusRestriction.add(Restrictions.and(Restrictions.eq("harvestStatus", expirationStatus),
            Restrictions.gt("harvestStartTime", expirationTime)));

    criteria.add(Restrictions.and(lastHarvestedRestriction, Restrictions.gt("harvestType", minimalType),
            statusRestriction

    ));
    criteria.addOrder(Order.asc("lastHarvested"));
    return list(criteria);

}

From source file:org.dspace.harvest.dao.impl.HarvestedCollectionDAOImpl.java

License:BSD License

protected Criteria getByStatusAndMinimalTypeCriteria(Context context, int status, int type, int limit)
        throws SQLException {
    Criteria criteria = createCriteria(context, HarvestedCollection.class);
    criteria.add(//from  ww w .ja  v a2 s.c  om
            Restrictions.and(Restrictions.gt("harvestType", type), Restrictions.eq("harvestStatus", status)));
    if (limit != -1) {
        criteria.setMaxResults(1);
    }
    return criteria;
}

From source file:org.dspace.harvest.dao.impl.HarvestedItemDAOImpl.java

License:BSD License

@Override
public HarvestedItem findByOAIId(Context context, String itemOaiID, Collection collection) throws SQLException {
    Criteria criteria = createCriteria(context, HarvestedItem.class);
    criteria.createAlias("item", "i");
    criteria.add(Restrictions.and(Restrictions.eq("oaiId", itemOaiID),
            Restrictions.eq("i.owningCollection", collection)));
    return singleResult(criteria);
}

From source file:org.dspace.orm.dao.database.BitstreamDao.java

License:BSD License

@SuppressWarnings("unchecked")
@Override//from   w w  w .  ja v  a2s . co  m
public List<Bitstream> selectDuplicateInternalIdentifier(Bitstream bitstream) {
    return (List<Bitstream>) super.getSession().createCriteria(Bitstream.class)
            .add(Restrictions.and(Restrictions.eq("internalId", bitstream.getInternalId()),
                    Restrictions.ne("ID", bitstream.getID())))
            .list();
}

From source file:org.dspace.orm.dao.database.HandleDao.java

License:BSD License

@Override
public Handle selectByResourceId(DSpaceObjectType resourseType, int id) {
    return (Handle) super.getSession().createCriteria(Handle.class).add(Restrictions
            .and(Restrictions.eq("resourceType", resourseType.getId()), Restrictions.eq("resourceId", id)))
            .uniqueResult();//from ww  w  .  ja  v  a 2s.  co m
}

From source file:org.dspace.orm.dao.database.MetadataValueDao.java

License:BSD License

@SuppressWarnings("unchecked")
@Override//from   w ww  . j  a  va  2  s . co  m
public List<MetadataValue> selectByResourceId(DSpaceObjectType resourceType, int resourceId) {
    return (List<MetadataValue>) this.getSession().createCriteria(MetadataValue.class)
            .add(Restrictions.and(Restrictions.eq("resourceType", resourceType.getId()),
                    Restrictions.eq("resource", resourceId)))
            .list();

}

From source file:org.dspace.xmlworkflow.storedcomponents.dao.impl.ClaimedTaskDAOImpl.java

License:BSD License

@Override
public ClaimedTask findByWorkflowItemAndEPerson(Context context, XmlWorkflowItem workflowItem, EPerson ePerson)
        throws SQLException {
    Criteria criteria = createCriteria(context, ClaimedTask.class);
    criteria.add(/*from www .  j a  v  a 2 s . c o m*/
            Restrictions.and(Restrictions.eq("workflowItem", workflowItem), Restrictions.eq("owner", ePerson)));

    return uniqueResult(criteria);
}

From source file:org.dspace.xmlworkflow.storedcomponents.dao.impl.ClaimedTaskDAOImpl.java

License:BSD License

@Override
public List<ClaimedTask> findByWorkflowItemAndStepId(Context context, XmlWorkflowItem workflowItem,
        String stepID) throws SQLException {
    Criteria criteria = createCriteria(context, ClaimedTask.class);
    criteria.add(//from w  w  w .  java 2  s .  c o  m
            Restrictions.and(Restrictions.eq("workflowItem", workflowItem), Restrictions.eq("stepId", stepID)));

    return list(criteria);
}