if (this.getTenant() != null) { comparison = this.getTenant().compareTo(that.getTenant()); if (comparison != EQUAL) { return comparison; } else if (that.getTenant() != null) { return BEFORE; if (this.getItem() != null) { comparison = this.getItem().compareTo(that.getItem()); if (comparison != EQUAL) { return comparison; } else if (that.getItem() != null) { return BEFORE; if (this.getType() != null) { comparison = this.getType().compareTo(that.getType()); if (comparison != EQUAL) { return comparison; } else if (that.getType() != null) { return BEFORE; assert this.equals(that) : "compareTo(...) inconsistent with equals(...)";
@Override public UserAssoc clone() throws CloneNotSupportedException { UserAssoc result = (UserAssoc) super.clone(); result.itemTo = itemTo.clone(); return result; }
private void validateItemTo(ItemVO<Integer, Integer> itemTo) { if (itemTo == null) { throw new IllegalArgumentException("missing ItemVO 'itemTo'"); } else if (itemTo.getItem() == null) { throw new IllegalArgumentException("missing value, ItemVO 'itemTo', missing 'id'"); } else if (itemTo.getType() == null) { throw new IllegalArgumentException("missing value, ItemVO 'itemTo', missing 'typeId'"); } }
public ClusterVO(Integer tenantId, Integer itemId, Integer itemTypeId, String name, String description) { item = new ItemVO<Integer,Integer>(tenantId, itemId, itemTypeId); this.name = name; this.description = description; }
public float match(ItemVO<Integer, String> item1, ItemVO<Integer, String> item2) { float ret = -1; try { ret = matchers.get(item1.getTenant()).get(item1.getType()).match(item1, item2); } catch (NullPointerException npe) { if (logger.isDebugEnabled()) { logger.debug("Could not match profiles! There seem to be no matchers defined for the given itemTypes!" + "TenantId: " + item1.getTenant() + " ItemTypeId1: " + item1.getType() + " ItemTypeId2: " + item2.getType()); } } return ret; }
/** * Checks if the item has the same tenant and item type are the same as the currently used values. * * @param item Item to check. */ private void validateItem(ItemVO<Integer, Integer> item) { Preconditions.checkNotNull(item, "item can't be null."); Preconditions.checkArgument(item.getTenant() == tenantId, "Tenant of item doesn't match."); }
@Override protected Map<Integer, RatingVO<Integer, Integer>> getAverageItemRatings(final Integer tenantId, final Integer itemTypeId) { final List<RatingVO<Integer, Integer>> averageItemRatings = getLatestActionDao() .getAverageRatingsForItem(tenantId, itemTypeId); final Map<Integer, RatingVO<Integer, Integer>> averageItemRatingsPerItem = new HashMap<Integer, RatingVO<Integer, Integer>>( averageItemRatings.size()); for (final RatingVO<Integer, Integer> rating : averageItemRatings) averageItemRatingsPerItem.put(rating.getItem().getItem(), rating); return averageItemRatingsPerItem; } }
/** * Checks whether the <code>Action</code> was performed on ("belongs to") the given item * * @param item the item to be compared to the item connected to the <code>Action</code> * @return <code>true</code> if the <code>Action</code> points to the given item, <code>false</code> else */ public boolean isBelongingToItem(ItemVO<I,T> item) { if (this.item == null) { if (item != null) { return false; } } else { return this.item.equals(item); } return true; }
private void validateNonEmptyFields(ActionVO<Integer, Integer> action, boolean useDateFromVO) { if (action.getTenant() == null) { throw new IllegalArgumentException( "missing constraints, unique key (tenantId, itemTypeId, actionTypeId, actionTime) must be set, missing 'tenantId'"); } if (action.getItem() == null) { throw new IllegalArgumentException( "missing constraints, unique key (tenantId, itemTypeId, actionTypeId, actionTime) must be set, missing 'item'"); } if (action.getItem().getType() == null) { throw new IllegalArgumentException( "missing constraints, unique key (tenantId, itemTypeId, actionTypeId, actionTime) must be set, missing 'itemTypeId'"); } if (action.getActionType() == null) { throw new IllegalArgumentException( "missing constraints, unique key (tenantId, itemTypeId, actionTypeId, actionTime) must be set, missing 'actionTypeId'"); } // in case of automatically generated 'actionTime' on database level leave out check for null if (useDateFromVO && action.getActionTime() == null) { throw new IllegalArgumentException( "missing constraints, unique key (tenantId, itemTypeId, actionTypeId, actionTime) must be set, missing 'actionTime'"); } }
@Override public int hashCode() { int hash = 3; hash = 89 * hash + (this.item != null ? this.item.hashCode() : 0); return hash; }
public Deviation(@Nullable Integer id, ItemVO<Integer, Integer> item1, ItemVO<Integer, Integer> item2, double numerator, long denominator) { validateItems(item1, item2); this.item1Id = item1.getItem(); this.item2Id = item2.getItem(); this.tenantId = item1.getTenant(); this.item1TypeId = item1.getType(); this.item2TypeId = item2.getType(); this.id = id; this.numerator = numerator; this.denominator = denominator; }
private void validateItemFrom(ItemVO<Integer, Integer> itemFrom) { if (itemFrom == null) { throw new IllegalArgumentException("missing ItemVO 'itemFrom'"); } else if (itemFrom.getItem() == null) { throw new IllegalArgumentException("missing value, ItemVO 'itemFrom', missing 'id'"); } else if (itemFrom.getType() == null) { throw new IllegalArgumentException("missing value, ItemVO 'itemFrom', missing 'typeId'"); } }
public ItemVO<Integer, Integer> mapRow(ResultSet rs, int rowNum) throws SQLException { return new ItemVO<Integer, Integer>(rs.getInt(BaseActionDAO.DEFAULT_TENANT_COLUMN_NAME), rs.getInt(BaseActionDAO.DEFAULT_ITEM_COLUMN_NAME), rs.getInt(BaseActionDAO.DEFAULT_ITEM_TYPE_COLUMN_NAME)); } };
public List<ItemVO<Integer, Integer>> getAvailableItemsForTenant(final Integer tenantId, final Integer itemTypeId) { Set<ItemVO<Integer, Integer>> result = new HashSet<ItemVO<Integer, Integer>>(); for (RatingVO<Integer, Integer> rating : ratings) { if (!tenantId.equals(rating.getItem().getTenant())) continue; if (!itemTypeId.equals(rating.getItem().getType())) continue; if (result.contains(rating.getItem())) continue; result.add(rating.getItem()); } return new ArrayList<ItemVO<Integer, Integer>>(result); }
/** * Checks if item1 and item2 have the same tenant and item type. * * @param item1 Item 1. * @param item2 Item 2. */ private void validateItems(ItemVO<Integer, Integer> item1, ItemVO<Integer, Integer> item2) { Preconditions.checkNotNull(item1, "item1 can't be null."); Preconditions.checkNotNull(item2, "item2 can't be null."); Preconditions.checkArgument(item1.getTenant().intValue() == item2.getTenant().intValue(), "Tenant of item1 and item2 doesn't match."); }
private List<RecommendedItemVO<Integer, Integer>> convertAssociatedItems( List<AssociatedItemVO<Integer, Integer>> associatedItems, ItemVO<Integer, Integer> currentItem) { List<RecommendedItemVO<Integer, Integer>> recommendedItems = new ArrayList<RecommendedItemVO<Integer, Integer>>(); for (AssociatedItemVO<Integer, Integer> currentAssociatedItem : associatedItems) { StringBuilder explanation = new StringBuilder(EXPLANATION_RELATED_1); explanation.append(currentItem.getItem()); explanation.append(EXPLANATION_RELATED_2); explanation.append(currentAssociatedItem.getAssocType()); explanation.append("'"); recommendedItems.add(new RecommendedItemVO<Integer, Integer>(currentAssociatedItem.getItem(), currentAssociatedItem.getAssocValue(), currentAssociatedItem.getItemAssocId(), explanation.toString())); } return recommendedItems; }
@Override public boolean equals(final Object o) { if (this == o) return true; if (!(o instanceof UserAssoc)) return false; final UserAssoc userAssoc = (UserAssoc) o; if (assocValue != null ? !assocValue.equals(userAssoc.assocValue) : userAssoc.assocValue != null) return false; if (changeDate != null ? !changeDate.equals(userAssoc.changeDate) : userAssoc.changeDate != null) return false; if (id != null ? !id.equals(userAssoc.id) : userAssoc.id != null) return false; if (itemTo != null ? !itemTo.equals(userAssoc.itemTo) : userAssoc.itemTo != null) return false; if (sourceTypeId != null ? !sourceTypeId.equals(userAssoc.sourceTypeId) : userAssoc.sourceTypeId != null) return false; if (tenantId != null ? !tenantId.equals(userAssoc.tenantId) : userAssoc.tenantId != null) return false; if (userFrom != null ? !userFrom.equals(userAssoc.userFrom) : userAssoc.userFrom != null) return false; return true; }
public int generateActions(int tenantId, TIntSet itemTypeIds, int actionTypeId, Date since) { Preconditions.checkNotNull(itemTypeIds); Preconditions.checkArgument(itemTypeIds.size() > 0, "at least one itemtype must be given"); if (since == null) since = getNewestActionDate(tenantId, itemTypeIds); if (isOnSameDataSourceAsEasyrec()) { Object[] args = new Object[]{tenantId, actionTypeId, since}; String query = QUERY_GENERATE.replace("@@@", generateItemTypeInClause(itemTypeIds)); return getJdbcTemplate().update(query, args, ARGT_GENERATE); } // when not on same datasource the tenantId is ignored and all actions are copied Iterator<ActionVO<Integer, Integer>> actions = actionDAO .getActionIterator(5000, new TimeConstraintVO(since, null)); int result = 0; while (actions.hasNext()) { ActionVO<Integer, Integer> actionVO = actions.next(); if (actionVO.getTenant() != tenantId) continue; if (actionVO.getActionType() != actionTypeId) continue; if (!itemTypeIds.contains(actionVO.getItem().getType())) continue; result += insertAction(actionVO); } return result; }