Example usage for org.hibernate.type StandardBasicTypes STRING

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

Introduction

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

Prototype

StringType STRING

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

Click Source Link

Document

The standard Hibernate type for mapping String to JDBC java.sql.Types#VARCHAR VARCHAR .

Usage

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

License:Open Source License

@Override
public List<Quote> findByUser(String userId) {
    Query query = getSession().createSQLQuery(RETRIEVE_QUOTE).addScalar("gooruOid", StandardBasicTypes.STRING)
            .addScalar("anchor", StandardBasicTypes.STRING).addScalar("freeText", StandardBasicTypes.STRING)
            .addScalar("topic", StandardBasicTypes.STRING).addScalar("title", StandardBasicTypes.STRING)
            .addScalar("grade", StandardBasicTypes.STRING).addScalar("licenseName", StandardBasicTypes.STRING)
            .addScalar("typeName", StandardBasicTypes.STRING).setParameter("contentUserId", userId);
    addOrgAuthParameters(query);//from   w w  w . j a  va 2s .  co  m
    List<Object[]> results = query.list();
    List<Quote> annotations = new ArrayList<Quote>();
    for (Object[] object : results) {
        Quote quote = new Quote();
        quote.setGooruOid((String) object[0]);
        quote.setAnchor((String) object[1]);
        quote.setFreetext((String) object[2]);
        quote.setTopic((String) object[3]);
        quote.setTitle((String) object[4]);
        quote.setGrade((String) object[5]);
        String licenseName = (String) object[6];
        License license = null;
        if (licenseName != null) {
            license = (License) get(License.class, licenseName);
        }

        quote.setLicense(license);

        String typeName = (String) object[7];

        TagType tagType = null;
        if (typeName != null) {
            tagType = (TagType) get(TagType.class, typeName);
        }

        quote.setTagType(tagType);
        annotations.add(quote);
    }
    return annotations;

}

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

License:Open Source License

public List<HashMap<String, String>> findSubscribedUsers(String gooruOid) {
    Query query = getSession().createSQLQuery(RETRIEVE_USERS).addScalar("createdOn", StandardBasicTypes.STRING)
            .addScalar("cont_userId", StandardBasicTypes.STRING)
            .addScalar("cont_firstname", StandardBasicTypes.STRING)
            .addScalar("cont_lastname", StandardBasicTypes.STRING)
            .addScalar("scb_userId", StandardBasicTypes.STRING).setParameter("gooruOid", gooruOid);
    addOrgAuthParameters(query);//from  w  ww .j  av a 2  s  .com
    List<Object[]> results = query.list();
    List<HashMap<String, String>> subscriptions = new ArrayList<HashMap<String, String>>();
    for (Object[] object : results) {
        HashMap<String, String> hMap = new HashMap<String, String>();
        hMap.put("subscribedOn", (String) object[0]);
        hMap.put("cont_userId", (String) object[1]);
        hMap.put("cont_firstname", (String) object[2]);
        hMap.put("cont_lastname", (String) object[3]);
        hMap.put("scb_userId", (String) object[4]);
        subscriptions.add(hMap);
    }
    return subscriptions;
}

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

License:Open Source License

public List<HashMap<String, String>> findSubscriptionsForUser(String gooruUid) {
    Query query = getSession().createSQLQuery(RETRIEVE_SUBSCRIPTION_FOR_USER)
            .addScalar("createdOn", StandardBasicTypes.STRING).addScalar("lessonId", StandardBasicTypes.STRING)
            .setParameter("gooruUid", gooruUid);
    addOrgAuthParameters(query);//from  w w  w . j  av  a  2  s .  co  m
    List<Object[]> results = query.list();

    List<HashMap<String, String>> subscriptions = new ArrayList<HashMap<String, String>>();
    for (Object[] object : results) {
        HashMap<String, String> hMap = new HashMap<String, String>();
        hMap.put("subscribedOn", (String) object[0]);
        hMap.put("lessonId", (String) object[1]);
        subscriptions.add(hMap);
    }
    return subscriptions;
}

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.classplan.LearnguideRepositoryHibernate.java

License:Open Source License

public List<Object> findByUser(User user, ResourceType.Type type) {
    String hql = LIST_LEARNGUIDE_BY_USER_ID;
    if (type != null) {
        hql = LIST_LEARNGUIDE_BY_USER_AND_LEARNGUIDE_TYPE;
    }/*from   www. ja  v  a  2  s .c o  m*/

    Query query = getSession().createQuery(hql);
    query.setParameter(0, user.getPartyUid(), StandardBasicTypes.STRING);
    addOrgAuthParameters(query);
    if (type != null) {
        query.setParameter("type", type.getType());
    }
    return query.list();
}

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

License:Open Source License

public List<Object> findAllLearnguides(ResourceType.Type type) {
    Query query = getSession().createQuery(LIST_CLASSPLAN);
    if (type != null) {
        query.setParameter(0, type.getType(), StandardBasicTypes.STRING);
    }/*from   ww w  .  j  a  v  a 2s. co  m*/
    addAuthParameters(query);
    return query.list();
}

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//from w ww .j a v a  2  s  .co m
            + "' 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.collaborator.CollaboratorRepositoryHibernate.java

License:Open Source License

@Override
public List<String> collaboratorSuggest(String text, String gooruUid) {
    String hql = "select external_id as mailId from  identity i inner join user_content_assoc uc on uc.user_uid = i.user_uid where uc.associated_by_uid=:gooruUid and i.external_id like '"
            + text.replace("'", "\\") + "%'";
    Query query = getSession().createSQLQuery(hql).addScalar("mailId", StandardBasicTypes.STRING);
    query.setParameter("gooruUid", gooruUid);
    return query.list();
}

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

License:Open Source License

@SuppressWarnings("unchecked")
@Override//from w ww .  java  2s  .  c o m
@Cacheable("persistent")
public Map<String, String> getConfigSettings(String organizationUid) {
    Session session = getSession();
    Map<String, String> settings = new HashMap<String, String>();

    Query query = session
            .createSQLQuery(GET_CONFIG_SETTING + " AND profile_id = '" + getConfigSettingProfileName() + "'")
            .addScalar("name", StandardBasicTypes.STRING).addScalar("value", StandardBasicTypes.STRING);
    query.setParameter(ORGANIZATION_UIDS, organizationUid);
    List<Object[]> results = query.list();
    for (Object[] object : results) {
        settings.put((String) object[0], (String) object[1]);
    }
    return settings;
}

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

License:Open Source License

@SuppressWarnings("unchecked")
@Override// w w  w .jav  a2 s .  c o m
@Cacheable("persistent")
public String getConfigSetting(String key, int securityLevel, String organizationUid) {
    String sql = "SELECT * FROM config_setting WHERE name = '" + key + "' AND security_level <= "
            + securityLevel + " AND profile_id = '" + getConfigSettingProfileName() + "' AND "
            + generateOrgAuthSqlQuery();
    Query query = getSession().createSQLQuery(sql).addScalar("value", StandardBasicTypes.STRING);
    query.setParameter(ORGANIZATION_UIDS, organizationUid);
    List<String> results = query.list();
    String value = null;
    if (results != null && results.size() > 0) {
        value = results.get(0);
    }
    return value;
}