Example usage for org.hibernate.type StandardBasicTypes INTEGER

List of usage examples for org.hibernate.type StandardBasicTypes INTEGER

Introduction

In this page you can find the example usage for org.hibernate.type StandardBasicTypes INTEGER.

Prototype

IntegerType INTEGER

To view the source code for org.hibernate.type StandardBasicTypes INTEGER.

Click Source Link

Document

The standard Hibernate type for mapping Integer to JDBC java.sql.Types#INTEGER INTEGER .

Usage

From source file:org.ednovo.gooru.infrastructure.persistence.hibernate.annotation.SubscriptionRepositoryHibernate.java

License:Open Source License

public Integer getSubscriptionCountForGooruOid(String contentGooruOid) {

    Query query = getSession().createSQLQuery(COUNT_SUBSCRIPTION_FOR_GOORUOID)
            .addScalar("totalCount", StandardBasicTypes.INTEGER).setParameter("gooruOid", contentGooruOid);
    addOrgAuthParameters(query);/*from w w  w.  ja v  a 2  s. co  m*/
    List<Integer> subscriptionCounts = query.list();

    if ((subscriptionCounts != null) && (subscriptionCounts.size() > 0)) {
        return subscriptionCounts.get(0);
    } else {
        return new Integer(0);
    }
}

From source file:org.ednovo.gooru.infrastructure.persistence.hibernate.assessment.AssessmentRepositoryHibernate.java

License:Open Source License

@Override
public Map<String, Object> getAssessmentAttemptsInfo(Integer attemptId, String gooruOAssessmentId,
        Integer studentId) {//from   w  w  w.  ja v  a2 s .c  o m
    String sql = "SELECT COUNT(1) as count, AVG(attempt.score) as avg FROM assessment_attempt attempt INNER JOIN content content ON content.gooru_oid = '"
            + gooruOAssessmentId
            + "' INNER JOIN assessment assessment ON ( assessment.assessment_id = content.content_id AND assessment.assessment_id = attempt.assessment_id )  WHERE attempt.mode = 1 AND attempt.attempt_id != '"
            + attemptId + "' AND attempt.student_id != " + studentId + " AND "
            + generateAuthSqlQueryWithData("content.");
    Query query = getSession().createSQLQuery(sql).addScalar("count", StandardBasicTypes.INTEGER)
            .addScalar("avg", StandardBasicTypes.DOUBLE);
    Object[] result = (Object[]) query.uniqueResult();
    Map<String, Object> resultMap = new HashMap<String, Object>();
    resultMap.put("otherAttempts", result[0]);
    resultMap.put("othersAvg", result[1]);
    return resultMap;
}

From source file:org.ednovo.gooru.infrastructure.persistence.hibernate.assessment.AssessmentRepositoryHibernate.java

License:Open Source License

@Override
public List<Object[]> getAssessmentAttemptQuestionSummary(Integer attemptId) {
    String sql = "SELECT question.question_text as questionText , question.type as questionType, question.concept as concept, attemptItem.attempt_status as status, question.question_id as questionId, question.explanation as explanation, resource.folder as folder, storageArea.area_path as assetURI "
            + " , content.gooru_oid as gooruOid ,  attemptItem.attempt_item_id as attemptItemId, attemptItem.correct_try_id as correctTrySequence  FROM assessment_attempt_item attemptItem "
            + " INNER JOIN assessment_question question ON question.question_id = attemptItem.question_id "
            + " INNER JOIN resource resource ON resource.content_id = question.question_id INNER JOIN content content ON resource.content_id = content.content_id  LEFT JOIN storage_area storageArea ON storageArea.storage_area_id = resource.storage_area_id  WHERE attemptItem.attempt_id = "
            + attemptId + " AND " + generateAuthSqlQueryWithData("content.");

    Query query = getSession().createSQLQuery(sql).addScalar("questionText", StandardBasicTypes.STRING)
            .addScalar("concept", StandardBasicTypes.STRING).addScalar("status", StandardBasicTypes.STRING)
            .addScalar("questionId", StandardBasicTypes.INTEGER)
            .addScalar("explanation", StandardBasicTypes.STRING)
            .addScalar("questionType", StandardBasicTypes.INTEGER)
            .addScalar("folder", StandardBasicTypes.STRING).addScalar("assetURI", StandardBasicTypes.STRING)
            .addScalar("gooruOid", StandardBasicTypes.STRING)
            .addScalar("attemptItemId", StandardBasicTypes.INTEGER)
            .addScalar("correctTrySequence", StandardBasicTypes.INTEGER);
    List<Object[]> result = query.list();
    return result;
}

From source file:org.ednovo.gooru.infrastructure.persistence.hibernate.assessment.AssessmentRepositoryHibernate.java

License:Open Source License

@Override
public Integer getCurrentTrySequence(Integer attemptItemId) {
    String sql = "SELECT MAX(attemptTry.try_sequence) as trySequence FROM assessment_attempt_try  attemptTry  INNER JOIN  assessment_answer answer ON (answer.answer_id = attemptTry.answer_id) INNER JOIN content content ON (answer.question_id=content.content_id)  WHERE attemptTry.attempt_item_id="
            + attemptItemId + " AND " + generateAuthSqlQueryWithData("content.");
    Session session = getSession();//w  w w .  j av a2 s .c  o  m
    Integer result = (Integer) session.createSQLQuery(sql).addScalar("trySequence", StandardBasicTypes.INTEGER)
            .uniqueResult();
    return result != null ? result + 1 : 1;
}

From source file:org.ednovo.gooru.infrastructure.persistence.hibernate.assessment.AssessmentRepositoryHibernate.java

License:Open Source License

@Override
public String getQuizUserScore(String gooruOAssessmentId, String studentId) {
    String sql = "SELECT Max(attempt.score) as maxScore FROM assessment_attempt attempt INNER JOIN content content ON content.gooru_oid = '"
            + gooruOAssessmentId/*from   w  w  w .j av  a 2 s  .c om*/
            + "' INNER JOIN assessment assessment ON ( assessment.assessment_id = content.content_id AND assessment.assessment_id = attempt.assessment_id ) WHERE  attempt.student_uid = '"
            + studentId + "'  AND  " + generateOrgAuthSqlQueryWithData("content.");

    Query query = getSession().createSQLQuery(sql).addScalar("maxScore", StandardBasicTypes.INTEGER);
    Integer result = (Integer) query.uniqueResult();
    return result != null ? result.toString() : "0";
}

From source file:org.ednovo.gooru.infrastructure.persistence.hibernate.classplan.LearnguideRepositoryHibernate.java

License:Open Source License

@Override
public List<User> findCollaborators(String gooruContentId, String userUid) {

    List<User> userList = new ArrayList<User>();
    String findCollaborators = "Select u.user_id, u.gooru_uid, u.firstname, u.lastname, i.external_id,u.username, u.organization_uid, u.primary_organization_uid from user u, content c , content_permission p, identity i where gooru_oid = '"
            + gooruContentId// w w  w  . j  a  va 2 s  .  c  om
            + "' and p.permission = 'edit' and u.gooru_uid = i.user_uid and c.content_id = p.content_id and u.gooru_uid = p.party_uid ";
    if (userUid != null) {
        findCollaborators += " and p.party_uid = '" + userUid + "'";
    }

    Session session = getSession();
    Query query = session.createSQLQuery(findCollaborators).addScalar("user_id", StandardBasicTypes.INTEGER)
            .addScalar("gooru_uid", StandardBasicTypes.STRING).addScalar("firstname", StandardBasicTypes.STRING)
            .addScalar("lastname", StandardBasicTypes.STRING)
            .addScalar("external_id", StandardBasicTypes.STRING)
            .addScalar("username", StandardBasicTypes.STRING)
            .addScalar("organization_uid", StandardBasicTypes.STRING)
            .addScalar("primary_organization_uid", StandardBasicTypes.STRING);

    List<Object[]> results = query.list();

    for (Object[] object : results) {
        Set<Identity> idSet = new HashSet<Identity>();
        User user = new User();
        Identity id = new Identity();

        user.setPartyUid((String) object[1]);
        user.setUserId((Integer) object[0]);
        user.setGooruUId((String) object[1]);
        user.setFirstName((String) object[2]);
        user.setLastName((String) object[3]);
        id.setExternalId((String) object[4]);
        user.setUsername((String) object[5]);
        String organizationUid = (String) object[6];
        if (organizationUid == null) {
            organizationUid = (String) object[7];
        }
        Organization organization = new Organization();
        organization.setPartyUid(organizationUid);
        user.setOrganization(organization);

        idSet.add(id);

        user.setIdentities(idSet);
        user.setEmailId(id.getExternalId());
        userList.add(user);
    }
    return userList;
}

From source file:org.ednovo.gooru.infrastructure.persistence.hibernate.content.ContentRepositoryHibernate.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override/*from   w w  w. j  a  v a2s. c om*/
public List<Object[]> getUserContentTagList(String gooruUid, Integer limit, Integer offset) {
    String sql = "select  count(1) as count, t.label as label , ct.tag_gooru_oid as tagGooruOid from tags t inner join content c on  (t.content_id = c.content_id) inner join content_tag_assoc ct on (c.gooru_oid= ct.tag_gooru_oid) where associated_uid  =  '"
            + gooruUid + "' group by ct.tag_gooru_oid";
    Query query = getSession().createSQLQuery(sql).addScalar("count", StandardBasicTypes.INTEGER)
            .addScalar("label", StandardBasicTypes.STRING).addScalar("tagGooruOid", StandardBasicTypes.STRING);
    query.setFirstResult(offset);
    query.setMaxResults(limit != null ? (limit > MAX_LIMIT ? MAX_LIMIT : limit) : LIMIT);
    return query.list();
}

From source file:org.ednovo.gooru.infrastructure.persistence.hibernate.content.ContentRepositoryHibernate.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override/*ww w  .  j a va2s.  co  m*/
public List<Object[]> getResourceContentTagList(String gooruOid, Integer limit, Integer offset) {
    String sql = "select  count(1) as count, t.label as label , ct.tag_gooru_oid as tagGooruOid from tags t inner join content c on  (t.content_id = c.content_id) inner join content_tag_assoc ct on (c.gooru_oid= ct.tag_gooru_oid) where content_gooru_oid  =  '"
            + gooruOid + "' group by ct.tag_gooru_oid";
    Query query = getSession().createSQLQuery(sql).addScalar("count", StandardBasicTypes.INTEGER)
            .addScalar("label", StandardBasicTypes.STRING).addScalar("tagGooruOid", StandardBasicTypes.STRING);
    query.setFirstResult(offset);
    query.setMaxResults(limit != null ? (limit > MAX_LIMIT ? MAX_LIMIT : limit) : LIMIT);
    return query.list();
}

From source file:org.ednovo.gooru.infrastructure.persistence.hibernate.featured.FeaturedRepositoryHibernate.java

License:Open Source License

@Override
public Integer getFeaturedSetId(String type) {
    String sql = "select featured_set_id as featuredSetId from featured_set f inner join custom_table_value ct on f.type_id = ct.custom_table_value_id   where theme_code = 'library' and ct.value ='"
            + type + "'";
    Query query = getSessionReadOnly().createSQLQuery(sql).addScalar("featuredSetId",
            StandardBasicTypes.INTEGER);
    return query.list().size() > 0 ? (Integer) query.list().get(0) : null;
}

From source file:org.ednovo.gooru.infrastructure.persistence.hibernate.FeedbackRepositoryHibernate.java

License:Open Source License

@Override
public Map<String, Object> getUserFeedbackRating(String assocUserUid, String feedbackRatingType) {
    Query query = getSession().createSQLQuery(FETCH_USER_FEEDBACK_RATING)
            .addScalar("score", StandardBasicTypes.INTEGER).addScalar("count", StandardBasicTypes.INTEGER)
            .setParameter("assocUserUid", assocUserUid).setParameter("feedbackRatingType", feedbackRatingType);
    return getRating(query.list());
}