@Override public Collection<TatamibotConfiguration> findTatamibotConfigurationsByDomain(String domain) { Set<TatamibotConfiguration> configurations = new HashSet<TatamibotConfiguration>(); ColumnSlice<UUID, String> results = HFactory.createSliceQuery( keyspaceOperator, StringSerializer.get(), UUIDSerializer.get(), StringSerializer.get()) .setColumnFamily(ColumnFamilyKeys.DOMAIN_TATAMIBOT_CF) .setKey(domain) .setRange(null, null, false, Integer.MAX_VALUE) .execute() .get(); for (HColumn<UUID, String> column : results.getColumns()) { String tatamibotConfigurationId = column.getName().toString(); TatamibotConfiguration configuration = em.find(TatamibotConfiguration.class, tatamibotConfigurationId); configurations.add(configuration); } return configurations; }
@Override @Cacheable("user-cache") public User findUserByLogin(String login) { User user = null; try { user = em.find(User.class, login); } catch (Exception e) { if (log.isDebugEnabled()) { log.debug("Exception while looking for user " + login + " : " + e.toString()); } return null; } if (user != null) { user.setStatusCount(counterRepository.getStatusCounter(login)); user.setFollowersCount(counterRepository.getFollowersCounter(login)); user.setFriendsCount(counterRepository.getFriendsCounter(login)); } return user; }
@Override @Cacheable("status-cache") public Status findStatusById(String statusId) { if (statusId == null || statusId.equals("")) { return null; } if (log.isDebugEnabled()) { log.debug("Finding status : " + statusId); } Status status = em.find(Status.class, statusId); if (status != null) { // Find status's tags List<String> tags = getTags(keyspaceOperator, STATUS_CF, statusId, TAG_COLUMN_MIN_NAME, TAG_COLUMN_MAX_NAME); status.setTags(tags); status = Boolean.TRUE.equals(status.getRemoved()) ? null : status; } return status; }
@Override public TatamibotConfiguration findTatamibotConfigurationById(String tatamibotConfigurationId) { return em.find(TatamibotConfiguration.class, tatamibotConfigurationId); }