Java 类org.hibernate.type.LongType 实例源码

项目:lams    文件:VoteUsrAttemptDAO.java   
@Override
   @SuppressWarnings("unchecked")
   public List<VoteStatsDTO> getStatisticsBySession(Long toolContentId) {

SQLQuery query = getSession().createSQLQuery(GET_STATISTICS);
query.addScalar("sessionUid", LongType.INSTANCE).addScalar("sessionName", StringType.INSTANCE)
    .addScalar("countUsersComplete", IntegerType.INSTANCE).setLong("contentId", toolContentId)
    .setResultTransformer(Transformers.aliasToBean(VoteStatsDTO.class));

return query.list();
   }
项目:sakai    文件:MessageForumsMessageManagerImpl.java   
public List<UserStatistics> findReadStatsForStudentByForumId(final String studentId, final Long forumId) {
    if (log.isDebugEnabled()) log.debug("findReadStatsForStudentByForumId()");

    HibernateCallback<List<Object[]>> hcb = session -> {
        Query q = session.getNamedQuery("findReadStatsForStudentByForumId");
        q.setParameter("userId", studentId, StringType.INSTANCE);
        q.setParameter("forumId", forumId, LongType.INSTANCE);
        return q.list();
    };
    List<UserStatistics> returnList = new ArrayList<UserStatistics>();
    List<Object[]> results = getHibernateTemplate().execute(hcb);
    for(Object[] result : results){
      UserStatistics stat = new UserStatistics((String) result[0], (String) result[1], (Date) result[2], (String) result[3], 
              ((Integer) result[4]).toString(), ((Integer) result[5]).toString(), ((Integer) result[6]).toString(), studentId);
      returnList.add(stat);
    }
    return returnList;
}
项目:sakai    文件:MessageForumsMessageManagerImpl.java   
public List<UserStatistics> findAuthoredStatsForStudentByForumId(final String studentId, final Long topicId) {
    if (log.isDebugEnabled()) log.debug("findAuthoredStatsForStudentByForumId()");

    HibernateCallback<List<Object[]>> hcb = session -> {
        Query q = session.getNamedQuery("findAuthoredStatsForStudentByForumId");
        q.setParameter("forumId", topicId, LongType.INSTANCE);
        q.setParameter("userId", studentId, StringType.INSTANCE);
        return q.list();
    };
    List<UserStatistics> returnList = new ArrayList<UserStatistics>();
    List<Object[]> results = getHibernateTemplate().execute(hcb);
    for(Object[] result : results){
        UserStatistics stat = new UserStatistics((String) result[0], (String) result[1], (Date) result[2], (String) result[3], 
                ((Integer) result[4]).toString(), ((Integer) result[5]).toString(), ((Integer) result[6]).toString(), studentId);
        returnList.add(stat);
    }
    return returnList;
}
项目:unitimes    文件:Location.java   
public Collection<Assignment> getAssignments(Collection<Long> solutionId) {
    if (solutionId.isEmpty()) return getCommitedAssignments();
    List<Assignment> ret = new ArrayList<Assignment>(new LocationDAO().getSession().createQuery(
            "select a from Assignment a inner join a.rooms r where " +
            "r.uniqueId = :locationId and a.solution.uniqueId in (:solutionIds)")
            .setLong("locationId", getUniqueId())
            .setParameterList("solutionIds", solutionId, new LongType())
            .setCacheable(true).list());
    ret.addAll(new LocationDAO().getSession().createQuery(
            "select a from Assignment a inner join a.rooms r where " +
            "r.uniqueId = :locationId and a.solution.commited = true and " +
            "a.solution.owner.uniqueId not in (select s.owner.uniqueId from Solution s where s.uniqueId in (:solutionIds))")
            .setLong("locationId", getUniqueId())
            .setParameterList("solutionIds", solutionId, new LongType())
            .setCacheable(true).list());
    return ret;
}
项目:unitimes    文件:TimetableGridSolutionHelper.java   
public static TimetableGridModel createModel(String solutionIdsStr, StudentGroupInfo g, org.hibernate.Session hibSession, TimetableGridContext context) {
    TimetableGridModel model = new TimetableGridModel(ResourceType.STUDENT_GROUP.ordinal(), g.getGroupId());
    model.setName(g.getGroupName());
    model.setFirstDay(context.getFirstDay());
    model.setFirstSessionDay(context.getFirstSessionDay());
    model.setFirstDate(context.getFirstDate());

List<Long> classIds = new ArrayList<Long>();
for (StudentGroupInfo.ClassInfo clazz: g.getGroupAssignments())
    classIds.add(clazz.getClassId());
if (classIds.isEmpty()) return null;

Query q = hibSession.createQuery(
        "select distinct a from Assignment a where a.solution.uniqueId in ("+solutionIdsStr+") and a.classId in (:classIds)");
q.setParameterList("classIds", classIds, new LongType());
q.setCacheable(true);
List assignments = q.list();
model.setSize((int)Math.round(g.countStudentWeights()));

for (Iterator i = assignments.iterator(); i.hasNext(); ) {
    Assignment assignment = (Assignment)i.next();
    List<TimetableGridCell> cells = createCells(model, assignment, hibSession, context, false); 
    StudentGroupInfo.ClassInfo ci = g.getGroupAssignment(assignment.getClassId());
    if (ci != null) {
        int total = g.countStudentsOfOffering(assignment.getClazz().getSchedulingSubpart().getInstrOfferingConfig().getInstructionalOffering().getUniqueId());
        for (TimetableGridCell cell: cells) {
            cell.setGroup("(" + Math.round(ci.countStudentsWeight()) + ")");
            if (ci.getStudents() != null && !ci.getStudents().isEmpty() && total > 1) {
                int assigned = ci.getStudents().size();
                int minLimit = assignment.getClazz().getExpectedCapacity();
                int maxLimit = assignment.getClazz().getMaxExpectedCapacity();
                int limit = maxLimit;
                if (minLimit < maxLimit) {
                    int roomLimit = (int) Math.floor(assignment.getPlacement().getRoomSize() / (assignment.getClazz().getRoomRatio() == null ? 1.0f : assignment.getClazz().getRoomRatio()));
                    // int roomLimit = Math.round((c.getRoomRatio() == null ? 1.0f : c.getRoomRatio()) * p.getRoomSize());
                    limit = Math.min(Math.max(minLimit, roomLimit), maxLimit);
                }
                   if (assignment.getClazz().getSchedulingSubpart().getInstrOfferingConfig().isUnlimitedEnrollment() || limit >= 9999) limit = Integer.MAX_VALUE;
                int p = 100 * assigned / Math.min(limit, total);
                cell.setBackground(percentage2color(p));
                cell.setPreference(assigned + " of " + total);
            }
        }
    }
}
model.setUtilization(g.getGroupValue());

return model;
  }
项目:unitimes    文件:SessionRestore.java   
protected Object get(Class clazz, String id) {
    if (clazz.equals(String.class) || clazz.equals(StringType.class)) return id;
    if (clazz.equals(Character.class) || clazz.equals(CharacterType.class)) return (id == null || id.isEmpty() ? null : id.charAt(0));
    if (clazz.equals(Byte.class) || clazz.equals(ByteType.class)) return Byte.valueOf(id);
    if (clazz.equals(Short.class) || clazz.equals(ShortType.class)) return Short.valueOf(id);
    if (clazz.equals(Integer.class) || clazz.equals(IntegerType.class)) return Integer.valueOf(id);
    if (clazz.equals(Long.class) || clazz.equals(LongType.class)) return Long.valueOf(id);
    if (clazz.equals(Float.class) || clazz.equals(FloatType.class)) return Float.valueOf(id);
    if (clazz.equals(Double.class) || clazz.equals(DoubleType.class)) return Double.valueOf(id);
    if (clazz.equals(Boolean.class) || clazz.equals(BooleanType.class)) return Boolean.valueOf(id);

    Map<String, Entity> entities = iEntities.get(clazz.getName());
    if (entities != null) {
        Entity entity = entities.get(id);
        if (entity != null) return entity.getObject();
    }
       for (Map.Entry<String, Map<String, Entity>> entry: iEntities.entrySet()) {
        Entity o = entry.getValue().get(id);
        if (o != null && clazz.isInstance(o.getObject())) return o.getObject();
    }
       if (clazz.equals(Session.class))
        return ((Entity)iEntities.get(Session.class.getName()).values().iterator().next()).getObject();
       if (clazz.equals(Student.class))
        return checkUnknown(clazz, id, iStudents.get(id));
       if (iIsClone)
        return checkUnknown(clazz, id,
                iHibSession.get(clazz, clazz.equals(ItypeDesc.class) ? (Serializable) Integer.valueOf(id) : (Serializable) Long.valueOf(id)));
       return checkUnknown(clazz, id, null);
}
项目:dkpro-jwpl    文件:Page.java   
/**
 * This is a more efficient shortcut for writing "getCategories().size()", as that would require
 * to load all the categories first.
 *
 * @return The number of categories.
 */
public int getNumberOfCategories()
{
    BigInteger nrOfCategories = new BigInteger("0");

    long id = __getId();
    Session session = wiki.__getHibernateSession();
     session.beginTransaction();
    Object returnValue = session
            .createNativeQuery("select count(pages) from page_categories where id = :pageid")
            .setParameter("pageid", id, LongType.INSTANCE).uniqueResult();
     session.getTransaction().commit();

    if (returnValue != null) {
        nrOfCategories = (BigInteger) returnValue;
    }
    return nrOfCategories.intValue();
}
项目:dkpro-jwpl    文件:Page.java   
/**
 * This is a more efficient shortcut for writing "getInlinks().size()", as that would require to
 * load all the inlinks first.
 *
 * @return The number of inlinks.
 */
public int getNumberOfInlinks()
{
    BigInteger nrOfInlinks = new BigInteger("0");

    long id = __getId();
    Session session = wiki.__getHibernateSession();
    session.beginTransaction();
    Object returnValue = session
            .createNativeQuery("select count(pi.inLinks) from page_inlinks as pi where pi.id = :piid")
            .setParameter("piid", id, LongType.INSTANCE).uniqueResult();
    session.getTransaction().commit();

    if (returnValue != null) {
        nrOfInlinks = (BigInteger) returnValue;
    }
    return nrOfInlinks.intValue();
}
项目:dkpro-jwpl    文件:Page.java   
/**
 * This is a more efficient shortcut for writing "getOutlinks().size()", as that would require
 * to load all the outlinks first.
 *
 * @return The number of outlinks.
 */
public int getNumberOfOutlinks()
{
    BigInteger nrOfOutlinks = new BigInteger("0");

    long id = __getId();
    Session session = wiki.__getHibernateSession();
    session.beginTransaction();
    Object returnValue = session
            .createNativeQuery("select count(outLinks) from page_outlinks where id = :id")
            .setParameter("id", id, LongType.INSTANCE).uniqueResult();
    session.getTransaction().commit();

    if (returnValue != null) {
        nrOfOutlinks = (BigInteger) returnValue;
    }
    return nrOfOutlinks.intValue();
}
项目:dkpro-jwpl    文件:Category.java   
/**
 * This is a more efficient shortcut for writing "getParents().size()", as that would require to load all the parents first.
 * @return The number of parents of this category.
 */
public int getNumberOfParents() {
    BigInteger nrOfInlinks = new BigInteger("0");

    long id = this.__getId();
    Session session = this.wiki.__getHibernateSession();
    session.beginTransaction();
    Object returnValue = session.createNativeQuery("select count(inLinks) from category_inlinks where id = :id")
        .setParameter("id", id, LongType.INSTANCE)
        .uniqueResult();
    session.getTransaction().commit();

    if (returnValue != null) {
        nrOfInlinks = (BigInteger) returnValue;
    }
    return nrOfInlinks.intValue();
}
项目:dkpro-jwpl    文件:Category.java   
/**
 * This is a more efficient shortcut for writing "getChildren().size()", as that would require to load all the children first.
 * @return The number of children of this category.
 */
public int getNumberOfChildren() {
    BigInteger nrOfOutlinks = new BigInteger("0");

    long id = this.__getId();
    Session session = this.wiki.__getHibernateSession();
    session.beginTransaction();
    Object returnValue = session.createNativeQuery("select count(outLinks) from category_outlinks where id = :id")
        .setParameter("id", id, LongType.INSTANCE)
        .uniqueResult();
    session.getTransaction().commit();

    if (returnValue != null) {
        nrOfOutlinks = (BigInteger) returnValue;
    }
    return nrOfOutlinks.intValue();
}
项目:dkpro-jwpl    文件:Category.java   
/**
 * This is a more efficient shortcut for writing "getPages().size()", as that would require to load all the pages first.
 * @return The number of pages.
 */
public int getNumberOfPages() throws WikiApiException {
    BigInteger nrOfPages = new BigInteger("0");

    long id = this.__getId();
    Session session = this.wiki.__getHibernateSession();
    session.beginTransaction();
    Object returnValue = session.createNativeQuery("select count(pages) from category_pages where id = :id")
        .setParameter("id", id, LongType.INSTANCE)
        .uniqueResult();
    session.getTransaction().commit();

    if (returnValue != null) {
        nrOfPages = (BigInteger) returnValue;
    }
    return nrOfPages.intValue();
}
项目:metaworks_framework    文件:TranslationServiceImpl.java   
protected String getEntityId(Object entity, TranslatedEntity entityType) {
    Map<String, Object> idMetadata = dao.getIdPropertyMetadata(entityType);
    String idProperty = (String) idMetadata.get("name");
    Type idType = (Type) idMetadata.get("type");

    if (!(idType instanceof LongType || idType instanceof StringType)) {
        throw new UnsupportedOperationException("Only ID types of String and Long are currently supported");
    }

    Object idValue = null;
    try {
        idValue = PropertyUtils.getProperty(entity, idProperty);
    } catch (Exception e) {
        throw new RuntimeException("Error reading id property", e);
    }

    if (idType instanceof StringType) {
        return (String) idValue;
    } else if (idType instanceof LongType) {
        return String.valueOf(idValue);
    }

    throw new IllegalArgumentException(String.format("Could not retrieve value for id property. Object: [%s], " +
            "ID Property: [%s], ID Type: [%s]", entity, idProperty, idType));
}
项目:SparkCommerce    文件:TranslationServiceImpl.java   
protected String getEntityId(Object entity, TranslatedEntity entityType) {
    Map<String, Object> idMetadata = dao.getIdPropertyMetadata(entityType);
    String idProperty = (String) idMetadata.get("name");
    Type idType = (Type) idMetadata.get("type");

    if (!(idType instanceof LongType || idType instanceof StringType)) {
        throw new UnsupportedOperationException("Only ID types of String and Long are currently supported");
    }

    Object idValue = null;
    try {
        idValue = PropertyUtils.getProperty(entity, idProperty);
    } catch (Exception e) {
        throw new RuntimeException("Error reading id property", e);
    }

    if (idType instanceof StringType) {
        return (String) idValue;
    } else if (idType instanceof LongType) {
        return String.valueOf(idValue);
    }

    throw new IllegalArgumentException(String.format("Could not retrieve value for id property. Object: [%s], " +
            "ID Property: [%s], ID Type: [%s]", entity, idProperty, idType));
}
项目:sakai    文件:RankManagerImpl.java   
public Rank getRankById(final Long rankId) {
    if (log.isDebugEnabled()) {
        log.debug("getRankById: " + rankId + ")");
    }

    if (rankId == null) {
        throw new IllegalArgumentException("getRankById(): rankId is null");
    }

    if (!isRanksEnabled())
    {
        // This is 'warn' because it implies some code is aware of a rank, but ranks are disabled
        log.warn("getRankById invoked, but ranks are disabled");
        return null;
    }

    HibernateCallback<Rank> hcb = session -> {
        Query q = session.getNamedQuery(QUERY_BY_RANK_ID);
        q.setParameter("rankId", rankId, LongType.INSTANCE);
        return (Rank) q.uniqueResult();
    };

    Rank rank = getHibernateTemplate().execute(hcb);
    return rank;
}
项目:sakai    文件:MessageForumsMessageManagerImpl.java   
public List<UserStatistics> findAuthoredStatsForStudentByTopicId(final String studentId, final Long topicId) {
    if (log.isDebugEnabled()) log.debug("findAuthoredStatsForStudentByTopicId()");

    HibernateCallback hcb = session -> {
        Query q = session.getNamedQuery("findAuthoredStatsForStudentByTopicId");
        q.setParameter("topicId", topicId, LongType.INSTANCE);
        q.setParameter("userId", studentId, StringType.INSTANCE);
        return q.list();
    };
    List<UserStatistics> returnList = new ArrayList<UserStatistics>();
    List<Object[]> results = (List<Object[]>)getHibernateTemplate().execute(hcb);
    for(Object[] result : results){
        UserStatistics stat = new UserStatistics((String) result[0], (String) result[1], (Date) result[2], (String) result[3], 
                ((Integer) result[4]).toString(), ((Integer) result[5]).toString(), ((Integer) result[6]).toString(), studentId);
        returnList.add(stat);
    }
    return returnList;
}
项目:sakai    文件:MessageForumsMessageManagerImpl.java   
public List<UserStatistics> findReadStatsForStudentByTopicId(final String studentId, final Long topicId) {
    if (log.isDebugEnabled()) log.debug("findReadStatsForStudentByTopicId()");

    HibernateCallback<List<Object[]>> hcb = session -> {
        Query q = session.getNamedQuery("findReadStatsForStudentByTopicId");
        q.setParameter("userId", studentId, StringType.INSTANCE);
        q.setParameter("topicId", topicId, LongType.INSTANCE);
        return q.list();
    };
    List<UserStatistics> returnList = new ArrayList<UserStatistics>();
    List<Object[]> results = getHibernateTemplate().execute(hcb);
    for(Object[] result : results){
      UserStatistics stat = new UserStatistics((String) result[0], (String) result[1], (Date) result[2], (String) result[3], 
              ((Integer) result[4]).toString(), ((Integer) result[5]).toString(), ((Integer) result[6]).toString(), studentId);
      returnList.add(stat);
    }
    return returnList;
}
项目:sakai    文件:MessageForumsMessageManagerImpl.java   
public List<UserStatistics> findReadStatsForStudentByForumId(final String studentId, final Long forumId) {
    if (log.isDebugEnabled()) log.debug("findReadStatsForStudentByForumId()");

    HibernateCallback<List<Object[]>> hcb = session -> {
        Query q = session.getNamedQuery("findReadStatsForStudentByForumId");
        q.setParameter("userId", studentId, StringType.INSTANCE);
        q.setParameter("forumId", forumId, LongType.INSTANCE);
        return q.list();
    };
    List<UserStatistics> returnList = new ArrayList<UserStatistics>();
    List<Object[]> results = getHibernateTemplate().execute(hcb);
    for(Object[] result : results){
      UserStatistics stat = new UserStatistics((String) result[0], (String) result[1], (Date) result[2], (String) result[3], 
              ((Integer) result[4]).toString(), ((Integer) result[5]).toString(), ((Integer) result[6]).toString(), studentId);
      returnList.add(stat);
    }
    return returnList;
}
项目:sakai    文件:MessageForumsMessageManagerImpl.java   
public List findMessagesByTopicId(final Long topicId) {
    if (topicId == null) {
        log.error("findMessagesByTopicId failed with topicId: null");
        throw new IllegalArgumentException("Null Argument");
    }

    log.debug("findMessagesByTopicId executing with topicId: " + topicId);

    HibernateCallback<List> hcb = session -> {
        Query q = session.getNamedQuery(QUERY_BY_TOPIC_ID);
        q.setParameter("topicId", topicId, LongType.INSTANCE);
        return q.list();
    };

    return getHibernateTemplate().execute(hcb);
}
项目:sakai    文件:MessageForumsMessageManagerImpl.java   
public List findUndeletedMessagesByTopicId(final Long topicId) {
    if (topicId == null) {
        log.error("findUndeletedMessagesByTopicId failed with topicId: null");
        throw new IllegalArgumentException("Null Argument");
    }

    log.debug("findUndeletedMessagesByTopicId executing with topicId: " + topicId);

    HibernateCallback<List> hcb = session -> {
        Query q = session.getNamedQuery(QUERY_UNDELETED_MSG_BY_TOPIC_ID);
        q.setParameter("topicId", topicId, LongType.INSTANCE);
        return q.list();
    };

    return getHibernateTemplate().execute(hcb);
}
项目:sakai    文件:MessageForumsMessageManagerImpl.java   
public UnreadStatus findUnreadStatusByUserId(final Long topicId, final Long messageId, final String userId){
    if (messageId == null || topicId == null || userId == null) {
        log.error("findUnreadStatusByUserId failed with topicId: " + topicId + ", messageId: " + messageId
                + ", userId: " + userId);
        throw new IllegalArgumentException("Null Argument");
    }

    log.debug("findUnreadStatus executing with topicId: " + topicId + ", messageId: " + messageId);

    HibernateCallback<UnreadStatus> hcb = session -> {
        Query q = session.getNamedQuery(QUERY_UNREAD_STATUS);
        q.setParameter("topicId", topicId, LongType.INSTANCE);
        q.setParameter("messageId", messageId, LongType.INSTANCE);
        q.setParameter("userId", userId, StringType.INSTANCE);
        return (UnreadStatus) q.uniqueResult();
    };

    return getHibernateTemplate().execute(hcb);
}
项目:sakai    文件:MessageForumsMessageManagerImpl.java   
/**
 * @see org.sakaiproject.api.app.messageforums.MessageForumsMessageManager#getMessageByIdWithAttachments(java.lang.Long)
 */
public Message getMessageByIdWithAttachments(final Long messageId){

  if (messageId == null) {
    throw new IllegalArgumentException("Null Argument");
   }

   log.debug("getMessageByIdWithAttachments executing with messageId: " + messageId);


  HibernateCallback<Message> hcb = session -> {
    Query q = session.getNamedQuery(QUERY_BY_MESSAGE_ID_WITH_ATTACHMENTS);
    q.setParameter("id", messageId, LongType.INSTANCE);
    return (Message) q.uniqueResult();
  };

  return getHibernateTemplate().execute(hcb);
}
项目:sakai    文件:MessageForumsMessageManagerImpl.java   
public void getChildMsgs(final Long messageId, List returnList)
{
    List tempList;

    HibernateCallback<List> hcb = session -> {
        Query q = session.getNamedQuery(QUERY_CHILD_MESSAGES);
        Query qOrdered = session.createQuery(q.getQueryString());

        qOrdered.setParameter("messageId", messageId, LongType.INSTANCE);

        return qOrdered.list();
    };

  tempList = getHibernateTemplate().execute(hcb);
  if(tempList != null)
  {
    for(int i=0; i<tempList.size(); i++)
    {
        getChildMsgs(((Message)tempList.get(i)).getId(), returnList);
        returnList.add((Message) tempList.get(i));
    }
  }
}
项目:sakai    文件:MessageForumsMessageManagerImpl.java   
public List findMovedMessagesByTopicId(final Long topicId) {
    if (topicId == null) {
        log.error("findMovedMessagesByTopicId failed with topicId: " + topicId);
        throw new IllegalArgumentException("Null Argument");
    }

    if (log.isDebugEnabled()) log.debug("findMovedMessagesByTopicId executing with topicId: " + topicId);

    HibernateCallback<List> hcb = session -> {
           Query q = session.getNamedQuery(QUERY_MOVED_MESSAGES_BY_TOPICID);
           q.setParameter("topicId", topicId, LongType.INSTANCE);
           return q.list();
       };

    return getHibernateTemplate().execute(hcb);
}
项目:sakai    文件:MessageForumsMessageManagerImpl.java   
public List findMovedHistoryByMessageId(final Long messageid){
    if (messageid == null) {
        log.error("findMovedHistoryByMessageId failed with messageid: " + messageid);
        throw new IllegalArgumentException("Null Argument");
    }

    if (log.isDebugEnabled()) log.debug("findMovedHistoryByMessageId executing with messageid: " + messageid);

    HibernateCallback<List> hcb = session -> {
           Query q = session.getNamedQuery(QUERY_MOVED_HISTORY_BY_MESSAGEID);
           q.setParameter("messageId", messageid, LongType.INSTANCE);
           return q.list();
       };

    return getHibernateTemplate().execute(hcb);

}
项目:sakai    文件:SyllabusManagerImpl.java   
/**
 * findLargestSyllabusPosition finds the largest syllabus data position for an item
 * @param syllabusItem
 */
public Integer findLargestSyllabusPosition(final SyllabusItem syllabusItem)      
{
  if (syllabusItem == null)
  {
    throw new IllegalArgumentException("Null Argument");
  }
  else
  {
    HibernateCallback<Integer> hcb = session -> {
      Query q = session.getNamedQuery(QUERY_LARGEST_POSITION);
      q.setParameter(FOREIGN_KEY, syllabusItem.getSurrogateKey(), LongType.INSTANCE);

      Integer position = (Integer) q.uniqueResult();

      if (position == null){
        return 0;
      }
      else{
        return position;
      }

    };
    return getHibernateTemplate().execute(hcb);
  }
}
项目:solidsearch-bot    文件:URLRestManager.java   
private void addScalars(SQLQuery query)
{
    query.addScalar("URI", StringType.INSTANCE);
    query.addScalar("foundTimestamp", LongType.INSTANCE);
    query.addScalar("canonicalTag", StringType.INSTANCE);
    query.addScalar("httpStatusCode", IntegerType.INSTANCE);
    query.addScalar("lastCrawledTimestamp", LongType.INSTANCE);
    query.addScalar("contentHashcode", StringType.INSTANCE);
    query.addScalar("backgroundId", ShortType.INSTANCE);
    query.addScalar("qualityScore", ShortType.INSTANCE);
    query.addScalar("spamScore", ShortType.INSTANCE);
    query.addScalar("readingLevel", ShortType.INSTANCE);
    query.addScalar("varietyTopicScore", ShortType.INSTANCE);
    query.addScalar("adScripts", ShortType.INSTANCE);
    query.addScalar("relevantImages", BooleanType.INSTANCE);
    query.addScalar("responseTime", IntegerType.INSTANCE);
    query.addScalar("pageSize", IntegerType.INSTANCE);
    query.addScalar("pageRank", DoubleType.INSTANCE);
    query.addScalar("qwLocale", StringType.INSTANCE);
    query.addScalar("onPageText", StringType.INSTANCE);
    query.addScalar("title", StringType.INSTANCE);
    query.addScalar("metaDescription", StringType.INSTANCE);
    query.addScalar("topicKeyword", StringType.INSTANCE);
    query.addScalar("robotsIndex", BooleanType.INSTANCE);
    query.addScalar("duplicateTitle", BooleanType.INSTANCE);
    query.addScalar("duplicateMetaDescription", BooleanType.INSTANCE);
    query.addScalar("duplicateContent", BooleanType.INSTANCE);
    query.addScalar("trailingSlashIssue", BooleanType.INSTANCE);
    query.addScalar("timeout", BooleanType.INSTANCE);
    query.addScalar("pagination", BooleanType.INSTANCE);
    query.addScalar("dcPrimary", BooleanType.INSTANCE);
}
项目:solidsearch-bot    文件:DomainRestManager.java   
private void addScalars(SQLQuery query)
{
    query.addScalar("resultFromTimestampMills", LongType.INSTANCE);
    query.addScalar("qualityScore", ShortType.INSTANCE);
    query.addScalar("totalLinks", LongType.INSTANCE);
    query.addScalar("internalURLs", LongType.INSTANCE);
    query.addScalar("internalNoindexURLs", LongType.INSTANCE);
    query.addScalar("internalIndexURLs", LongType.INSTANCE);
    query.addScalar("externalURLs", LongType.INSTANCE);
    query.addScalar("externalURLsDifferentDomains", LongType.INSTANCE);
    query.addScalar("crawledURLs", LongType.INSTANCE);
    query.addScalar("clientErrorURLs", LongType.INSTANCE);
    query.addScalar("timeoutURLs", LongType.INSTANCE);
    query.addScalar("redirectionURLs", LongType.INSTANCE);
    query.addScalar("serverErrorURLs", LongType.INSTANCE);
    query.addScalar("avgResponseTimeMills", IntegerType.INSTANCE);
    query.addScalar("medianResponseTimeMills", IntegerType.INSTANCE);
    query.addScalar("avgPageSize", LongType.INSTANCE);
    query.addScalar("totalCountOfRelevantKeywords", LongType.INSTANCE);
    query.addScalar("totalCountOfKeywords", LongType.INSTANCE);
    query.addScalar("avgReadingLevel", DoubleType.INSTANCE);
    query.addScalar("domainBrandName", StringType.INSTANCE);
    query.addScalar("homeDocument", StringType.INSTANCE);
}
项目:blcdemo    文件:TranslationDaoImpl.java   
@Override
public String getEntityId(TranslatedEntity entityType, Object entity) {
    Map<String, Object> idMetadata = getIdPropertyMetadata(entityType);
    String idProperty = (String) idMetadata.get("name");
    Type idType = (Type) idMetadata.get("type");

    if (!(idType instanceof LongType || idType instanceof StringType)) {
        throw new UnsupportedOperationException("Only ID types of String and Long are currently supported");
    }

    Object idValue;
    try {
        idValue = PropertyUtils.getProperty(entity, idProperty);
    } catch (Exception e) {
        throw new RuntimeException("Error reading id property", e);
    }

    if (idType instanceof StringType) {
        return (String) idValue;
    } else if (idType instanceof LongType) {
        return getUpdatedEntityId(entityType, (Long) idValue);
    }

    throw new IllegalArgumentException(String.format("Could not retrieve value for id property. Object: [%s], " +
            "ID Property: [%s], ID Type: [%s]", entity, idProperty, idType));
}
项目:unitime    文件:Location.java   
public Collection<Assignment> getAssignments(Collection<Long> solutionId) {
    if (solutionId.isEmpty()) return getCommitedAssignments();
    List<Assignment> ret = new ArrayList<Assignment>(new LocationDAO().getSession().createQuery(
            "select a from Assignment a inner join a.rooms r where " +
            "r.uniqueId = :locationId and a.solution.uniqueId in (:solutionIds)")
            .setLong("locationId", getUniqueId())
            .setParameterList("solutionIds", solutionId, new LongType())
            .setCacheable(true).list());
    ret.addAll(new LocationDAO().getSession().createQuery(
            "select a from Assignment a inner join a.rooms r where " +
            "r.uniqueId = :locationId and a.solution.commited = true and " +
            "a.solution.owner.uniqueId not in (select s.owner.uniqueId from Solution s where s.uniqueId in (:solutionIds))")
            .setLong("locationId", getUniqueId())
            .setParameterList("solutionIds", solutionId, new LongType())
            .setCacheable(true).list());
    return ret;
}
项目:sakai    文件:RankManagerImpl.java   
public Rank getRankById(final Long rankId) {
    if (log.isDebugEnabled()) {
        log.debug("getRankById: " + rankId + ")");
    }

    if (rankId == null) {
        throw new IllegalArgumentException("getRankById(): rankId is null");
    }

    if (!isRanksEnabled())
    {
        // This is 'warn' because it implies some code is aware of a rank, but ranks are disabled
        log.warn("getRankById invoked, but ranks are disabled");
        return null;
    }

    HibernateCallback<Rank> hcb = session -> {
        Query q = session.getNamedQuery(QUERY_BY_RANK_ID);
        q.setParameter("rankId", rankId, LongType.INSTANCE);
        return (Rank) q.uniqueResult();
    };

    Rank rank = getHibernateTemplate().execute(hcb);
    return rank;
}
项目:sakai    文件:MessageForumsMessageManagerImpl.java   
public List<UserStatistics> findAuthoredStatsForStudentByTopicId(final String studentId, final Long topicId) {
    if (log.isDebugEnabled()) log.debug("findAuthoredStatsForStudentByTopicId()");

    HibernateCallback hcb = session -> {
        Query q = session.getNamedQuery("findAuthoredStatsForStudentByTopicId");
        q.setParameter("topicId", topicId, LongType.INSTANCE);
        q.setParameter("userId", studentId, StringType.INSTANCE);
        return q.list();
    };
    List<UserStatistics> returnList = new ArrayList<UserStatistics>();
    List<Object[]> results = (List<Object[]>)getHibernateTemplate().execute(hcb);
    for(Object[] result : results){
        UserStatistics stat = new UserStatistics((String) result[0], (String) result[1], (Date) result[2], (String) result[3], 
                ((Integer) result[4]).toString(), ((Integer) result[5]).toString(), ((Integer) result[6]).toString(), studentId);
        returnList.add(stat);
    }
    return returnList;
}
项目:sakai    文件:MessageForumsMessageManagerImpl.java   
public List<UserStatistics> findAuthoredStatsForStudentByForumId(final String studentId, final Long topicId) {
    if (log.isDebugEnabled()) log.debug("findAuthoredStatsForStudentByForumId()");

    HibernateCallback<List<Object[]>> hcb = session -> {
        Query q = session.getNamedQuery("findAuthoredStatsForStudentByForumId");
        q.setParameter("forumId", topicId, LongType.INSTANCE);
        q.setParameter("userId", studentId, StringType.INSTANCE);
        return q.list();
    };
    List<UserStatistics> returnList = new ArrayList<UserStatistics>();
    List<Object[]> results = getHibernateTemplate().execute(hcb);
    for(Object[] result : results){
        UserStatistics stat = new UserStatistics((String) result[0], (String) result[1], (Date) result[2], (String) result[3], 
                ((Integer) result[4]).toString(), ((Integer) result[5]).toString(), ((Integer) result[6]).toString(), studentId);
        returnList.add(stat);
    }
    return returnList;
}
项目:sakai    文件:MessageForumsMessageManagerImpl.java   
public List<UserStatistics> findReadStatsForStudentByTopicId(final String studentId, final Long topicId) {
    if (log.isDebugEnabled()) log.debug("findReadStatsForStudentByTopicId()");

    HibernateCallback<List<Object[]>> hcb = session -> {
        Query q = session.getNamedQuery("findReadStatsForStudentByTopicId");
        q.setParameter("userId", studentId, StringType.INSTANCE);
        q.setParameter("topicId", topicId, LongType.INSTANCE);
        return q.list();
    };
    List<UserStatistics> returnList = new ArrayList<UserStatistics>();
    List<Object[]> results = getHibernateTemplate().execute(hcb);
    for(Object[] result : results){
      UserStatistics stat = new UserStatistics((String) result[0], (String) result[1], (Date) result[2], (String) result[3], 
              ((Integer) result[4]).toString(), ((Integer) result[5]).toString(), ((Integer) result[6]).toString(), studentId);
      returnList.add(stat);
    }
    return returnList;
}
项目:sakai    文件:MessageForumsMessageManagerImpl.java   
public List findMessagesByTopicId(final Long topicId) {
    if (topicId == null) {
        log.error("findMessagesByTopicId failed with topicId: null");
        throw new IllegalArgumentException("Null Argument");
    }

    log.debug("findMessagesByTopicId executing with topicId: " + topicId);

    HibernateCallback<List> hcb = session -> {
        Query q = session.getNamedQuery(QUERY_BY_TOPIC_ID);
        q.setParameter("topicId", topicId, LongType.INSTANCE);
        return q.list();
    };

    return getHibernateTemplate().execute(hcb);
}
项目:sakai    文件:MessageForumsMessageManagerImpl.java   
public List findUndeletedMessagesByTopicId(final Long topicId) {
    if (topicId == null) {
        log.error("findUndeletedMessagesByTopicId failed with topicId: null");
        throw new IllegalArgumentException("Null Argument");
    }

    log.debug("findUndeletedMessagesByTopicId executing with topicId: " + topicId);

    HibernateCallback<List> hcb = session -> {
        Query q = session.getNamedQuery(QUERY_UNDELETED_MSG_BY_TOPIC_ID);
        q.setParameter("topicId", topicId, LongType.INSTANCE);
        return q.list();
    };

    return getHibernateTemplate().execute(hcb);
}
项目:sakai    文件:MessageForumsMessageManagerImpl.java   
public UnreadStatus findUnreadStatusByUserId(final Long topicId, final Long messageId, final String userId){
    if (messageId == null || topicId == null || userId == null) {
        log.error("findUnreadStatusByUserId failed with topicId: " + topicId + ", messageId: " + messageId
                + ", userId: " + userId);
        throw new IllegalArgumentException("Null Argument");
    }

    log.debug("findUnreadStatus executing with topicId: " + topicId + ", messageId: " + messageId);

    HibernateCallback<UnreadStatus> hcb = session -> {
        Query q = session.getNamedQuery(QUERY_UNREAD_STATUS);
        q.setParameter("topicId", topicId, LongType.INSTANCE);
        q.setParameter("messageId", messageId, LongType.INSTANCE);
        q.setParameter("userId", userId, StringType.INSTANCE);
        return (UnreadStatus) q.uniqueResult();
    };

    return getHibernateTemplate().execute(hcb);
}
项目:sakai    文件:MessageForumsMessageManagerImpl.java   
/**
 * @see org.sakaiproject.api.app.messageforums.MessageForumsMessageManager#getMessageByIdWithAttachments(java.lang.Long)
 */
public Message getMessageByIdWithAttachments(final Long messageId){

  if (messageId == null) {
    throw new IllegalArgumentException("Null Argument");
   }

   log.debug("getMessageByIdWithAttachments executing with messageId: " + messageId);


  HibernateCallback<Message> hcb = session -> {
    Query q = session.getNamedQuery(QUERY_BY_MESSAGE_ID_WITH_ATTACHMENTS);
    q.setParameter("id", messageId, LongType.INSTANCE);
    return (Message) q.uniqueResult();
  };

  return getHibernateTemplate().execute(hcb);
}
项目:sakai    文件:MessageForumsMessageManagerImpl.java   
public void getChildMsgs(final Long messageId, List returnList)
{
    List tempList;

    HibernateCallback<List> hcb = session -> {
        Query q = session.getNamedQuery(QUERY_CHILD_MESSAGES);
        Query qOrdered = session.createQuery(q.getQueryString());

        qOrdered.setParameter("messageId", messageId, LongType.INSTANCE);

        return qOrdered.list();
    };

  tempList = getHibernateTemplate().execute(hcb);
  if(tempList != null)
  {
    for(int i=0; i<tempList.size(); i++)
    {
        getChildMsgs(((Message)tempList.get(i)).getId(), returnList);
        returnList.add((Message) tempList.get(i));
    }
  }
}
项目:sakai    文件:MessageForumsMessageManagerImpl.java   
public List findMovedMessagesByTopicId(final Long topicId) {
    if (topicId == null) {
        log.error("findMovedMessagesByTopicId failed with topicId: " + topicId);
        throw new IllegalArgumentException("Null Argument");
    }

    if (log.isDebugEnabled()) log.debug("findMovedMessagesByTopicId executing with topicId: " + topicId);

    HibernateCallback<List> hcb = session -> {
           Query q = session.getNamedQuery(QUERY_MOVED_MESSAGES_BY_TOPICID);
           q.setParameter("topicId", topicId, LongType.INSTANCE);
           return q.list();
       };

    return getHibernateTemplate().execute(hcb);
}