当前位置: 首页>>代码示例>>Java>>正文


Java RemoteTenant.getId方法代码示例

本文整理汇总了Java中org.easyrec.model.core.web.RemoteTenant.getId方法的典型用法代码示例。如果您正苦于以下问题:Java RemoteTenant.getId方法的具体用法?Java RemoteTenant.getId怎么用?Java RemoteTenant.getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.easyrec.model.core.web.RemoteTenant的用法示例。


在下文中一共展示了RemoteTenant.getId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: get

import org.easyrec.model.core.web.RemoteTenant; //导入方法依赖的package包/类
@Override
public Item get(RemoteTenant remoteTenant, String itemId, String itemType) {
    String cacheId = makeCacheKey(remoteTenant.getId(), itemType, itemId);

    Element e = cache.get(cacheId);

    if (e != null) {
        return (Item) e.getValue();
    } else {
        Object[] args = {remoteTenant.getId(), itemId, itemType};

        try {
            Item i = getJdbcTemplate().query(PS_GET_ITEM.newPreparedStatementCreator(args), itemRowMapper).get(0);
            i.setUrl(Text.matchMax(remoteTenant.getUrl(), i.getUrl()));
            i.setImageUrl(Text.matchMax(remoteTenant.getUrl(), i.getImageUrl()));
            cache.put(new Element(cacheId, i));

            return i;
        } catch (Exception ex) {
            if (logger.isDebugEnabled())
                logger.debug("failed to get item or failed to insert it into the cache", ex);
            return null;
        }
    }
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:26,代码来源:ItemDAOMysqlImpl.java

示例2: getItems

import org.easyrec.model.core.web.RemoteTenant; //导入方法依赖的package包/类
@Override
public List<Item> getItems(RemoteTenant remoteTenant, String description, int start, int end) {
    List<Item> items;

    Object[] args = {remoteTenant.getId(), Item.DEFAULT_STRING_ITEM_TYPE};
    int[] argTypes = {Types.INTEGER, Types.VARCHAR};

    StringBuilder sql = new StringBuilder(SQL_GET_ITEMS);
    sql = MySQL.addLikeClause(sql, "DESCRIPTION", description);
    sql = MySQL.addLimitClause(sql, start, end);

    try {
        items = getJdbcTemplate().query(sql.toString(), args, argTypes, itemRowMapper);

        for (final Object item1 : items) {
            Item item = (Item) item1;
            item.setUrl(Text.matchMax(remoteTenant.getUrl(), item.getUrl()));
            item.setImageUrl(Text.matchMax(remoteTenant.getUrl(), item.getImageUrl()));
        }

        return items;
    } catch (Exception e) {
        logger.warn("An error occurred!", e);
        return null;
    }
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:27,代码来源:ItemDAOMysqlImpl.java

示例3: getHotItems

import org.easyrec.model.core.web.RemoteTenant; //导入方法依赖的package包/类
@Override
public List<Item> getHotItems(RemoteTenant remoteTenant, Integer start, Integer end) {
    List<Item> items;

    Object[] args = {remoteTenant.getId()};
    int[] argTypes = {Types.INTEGER};

    try {
        items = getJdbcTemplate()
                .query(new StringBuilder(SQL_HOT_ITEMS).append(" LIMIT ").append(start).append(", ").append(end)
                        .toString(), args, argTypes, itemRowMapper);
        for (final Object item1 : items) {
            Item item = (Item) item1;
            item.setUrl(Text.matchMax(remoteTenant.getUrl(), item.getUrl()));
            item.setImageUrl(Text.matchMax(remoteTenant.getUrl(), item.getImageUrl()));
        }
        return items;
    } catch (Exception e) {
        logger.warn("An error occurred!", e);
        return null;
    }
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:23,代码来源:ItemDAOMysqlImpl.java

示例4: getTenantStatistics

import org.easyrec.model.core.web.RemoteTenant; //导入方法依赖的package包/类
/**
 * Compute tenant statistics for
 * recommendation_coverage: Number of total actions of items that are in the itemassoc table.
 * 10M entries/tenant: average computation time 4,5 minutes
 */
@Override
public TenantStatistic getTenantStatistics(RemoteTenant remoteTenant) {

    Integer tenantId = remoteTenant.getId();
    // will be replaced with the actual l1 size as soon l1 is configureable
    // in the administration menu.
    Integer l1 = 5000;

    String sql = new StringBuilder().append(" SELECT  ").append("     a.actions, ").append("     b.backtracks, ")
            .append("     i.items, ").append("     u.users, ")
            .append("     ROUND(a.actions/u.users,2) AS average_actions_per_user, ")
            .append("     ROUND((e.number_of_total_actions_of_items_in_itemassoc/a.actions)*100,2) as recommendation_coverage ")
            .append(" FROM ").append(" (SELECT count(1) as actions FROM action WHERE tenantid=?) a JOIN  ")
            .append(" (SELECT count(1) as backtracks FROM backtracking WHERE tenantid=?) b JOIN  ")
            .append(" (SELECT count(1) as items FROM (SELECT distinct itemid FROM action where tenantid = ?) a) i JOIN  ")
            .append(" (SELECT count(1) as users FROM (SELECT distinct userid FROM action where tenantid = ?) a) u JOIN ")
            .append(" (SELECT SUM(c) AS number_of_total_actions_of_items_in_itemassoc FROM ( ")
            .append("   SELECT c FROM  ").append("       (SELECT itemid, itemtypeid, tenantid, COUNT(1) as c ")
            .append("        FROM action  ").append("        WHERE  ").append("           tenantid = ?   ")
            .append("        GROUP BY  ").append("           itemid ").append("        LIMIT ").append(l1)
            .append("        ) a INNER JOIN itemassoc i ON (  ").append("           i.itemfromid = a.itemid AND   ")
            .append("           a.itemtypeid = i.itemFromTypeId AND  ")
            .append("           a.tenantid   = i.tenantid)  ").append("       GROUP BY   ")
            .append("           a.itemid, a.itemtypeid, a.tenantid  ").append("       ) a) e  ").toString();

    TenantStatistic t = getJdbcTemplate()
            .queryForObject(sql, new Object[]{tenantId, tenantId, tenantId, tenantId, tenantId},
                    new int[]{Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER},
                    tenantStatisticRowMapper);

    return t;
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:38,代码来源:StatisticsDAOMySql.java


注:本文中的org.easyrec.model.core.web.RemoteTenant.getId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。