@Override public ItemAssocVO<Integer, String> convertItemAssocVO(Integer tenantId, ItemAssocVO<Integer,Integer> itemAssoc) { if (itemAssoc == null) { return null; } return new ItemAssocVO<Integer, String>( itemAssoc.getId(), itemAssoc.getTenant(), convertItemVO(tenantId, itemAssoc.getItemFrom()), assocTypeDAO.getTypeById(tenantId, itemAssoc.getAssocType()), itemAssoc.getAssocValue(), convertItemVO(tenantId, itemAssoc.getItemTo()), sourceTypeDAO.getTypeById(tenantId, itemAssoc.getSourceType()), itemAssoc.getSourceInfo(), viewTypeDAO.getTypeById(tenantId, itemAssoc.getViewType()), itemAssoc.isActive(), itemAssoc.getChangeDate()); }
@SuppressWarnings("unchecked") @Override public ItemAssocVO<I,T> clone() throws CloneNotSupportedException { ItemAssocVO<I,T> clonedIAssocVO = (ItemAssocVO<I,T>) super.clone(); clonedIAssocVO.setItemFrom(clonedIAssocVO.getItemFrom().clone()); clonedIAssocVO.setItemTo(clonedIAssocVO.getItemTo().clone()); return clonedIAssocVO; } }
if (itemAssoc.getId() == null) { if (itemAssoc.getAssocValue() != null && !itemAssoc.getAssocValue().equals(itemAssocResult.getAssocValue()) || itemAssoc.getViewType() != null && !itemAssoc.getViewType().equals(itemAssocResult.getViewType()) || itemAssoc.isActive() != null && !itemAssoc.isActive().equals(itemAssocResult.isActive())) { rowsAffected = itemAssocDAO.updateItemAssocUsingUniqueKey(itemAssoc); itemAssoc.setId(itemAssocResult.getId());
try { iAssoc = (ItemAssocVO<Integer,Integer>) headerDefaults .clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException( iAssoc.setTenant(Integer.parseInt(elementsOfLine[0])); } catch (NumberFormatException nfe) { if (commandEqualsInsertCommand) { if (commandEqualsInsertCommand && iAssoc.getTenant() == null) { AutoImportUtils .logSkippedLine(logger, lineCounter, line, "no value for field 'tenantId' is set"); iAssoc.getItemFrom().setItem(Integer.parseInt(elementsOfLine[1])); } catch (NumberFormatException nfe) { if (commandEqualsInsertCommand) { if (commandEqualsInsertCommand && iAssoc.getItemFrom().getItem() == null) { AutoImportUtils.logSkippedLine(logger, lineCounter, line, "no value for field 'itemFromId' is set"); iAssoc.getItemFrom().setType(Integer.parseInt(elementsOfLine[2])); } catch (NumberFormatException nfe) { if (commandEqualsInsertCommand) { if (commandEqualsInsertCommand && iAssoc.getItemFrom().getType() == null) { AutoImportUtils.logSkippedLine(logger, lineCounter, line, "no value for field 'itemFromTypeId' is set");
private void validateUniqueKey(ItemAssocVO<Integer,Integer> itemAssoc) { if (itemAssoc.getItemFrom() == null) { throw new IllegalArgumentException( "missing constraints, unique key (tenantId,itemFromId,itemToId,itemFromType,itemToType,assocType,sourceType) must be set, missing 'itemFrom'"); if (itemAssoc.getItemTo() == null) { throw new IllegalArgumentException( "missing constraints, unique key (tenantId,itemFromId,itemToId,itemFromType,itemToType,assocType,sourceType) must be set, missing 'itemTo'"); if (itemAssoc.getItemFrom().getItem() == null) { throw new IllegalArgumentException( "missing constraints, unique key (tenantId,itemFromId,itemToId,itemFromType,itemToType,assocType,sourceType) must be set, missing 'itemFromId'"); if (itemAssoc.getItemFrom().getType() == null) { throw new IllegalArgumentException( "missing constraints, unique key (tenantId,itemFromId,itemToId,itemFromType,itemToType,assocType,sourceType) must be set, missing 'itemFromTypeId'"); if (itemAssoc.getItemTo().getItem() == null) { throw new IllegalArgumentException( "missing constraints, unique key (tenantId,itemFromId,itemToId,itemFromType,itemToType,assocType,sourceType) must be set, missing 'itemToId'"); if (itemAssoc.getItemTo().getType() == null) { throw new IllegalArgumentException( "missing constraints, unique key (tenantId,itemFromId,itemToId,itemFromType,itemToType,assocType,sourceType) must be set, missing 'itemToTypeId'"); if (itemAssoc.getAssocType() == null) { throw new IllegalArgumentException( "missing constraints, unique key (tenantId,itemFromId,itemToId,itemFromType,itemToType,assocType,sourceType) must be set, missing 'assocTypeId'"); if (itemAssoc.getSourceType() == null) {
public int removeAllItemAssocsFromSource(Integer sourceTypeId, String sourceInfo) { return itemAssocDAO.removeItemAssocsQBE( new ItemAssocVO<Integer,Integer>(null, null, null, null, null, sourceTypeId, sourceInfo, null, null)); }
if (defaults != null) { try { iAssoc = (ItemAssocVO<Integer,Integer>) defaults.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException( iAssoc = new ItemAssocVO<Integer,Integer>(null, null, new ItemVO<Integer, Integer>(null, null, null), null, null, new ItemVO<Integer, Integer>(null, null, null), null, null, null, null); if (defaultValue != null) { try { iAssoc.setTenant(Integer.parseInt(defaultValue)); } catch (NumberFormatException nfe) { logger.warn("the default value for 'tenantId' in the CSV header is no valid 'Integer', passed type='" + if (defaultValue != null) { try { iAssoc.getItemFrom().setType(Integer.parseInt(defaultValue)); } catch (NumberFormatException nfe) { logger.warn( if (defaultValue != null) { try { iAssoc.setAssocType(Integer.parseInt(defaultValue)); } catch (NumberFormatException nfe) { logger.warn( if (defaultValue != null) {
sqlString.append(DEFAULT_VIEW_TYPE_COLUMN_NAME); sqlString.append("=?, "); if (itemAssoc.isActive() != null) { sqlString.append(DEFAULT_ACTIVE_COLUMN_NAME); sqlString.append("=?, "); if (itemAssoc.getChangeDate() == null) { itemAssoc.setChangeDate(new Date(System.currentTimeMillis())); if (itemAssoc.isActive() != null) { args = new Object[]{itemAssoc.getAssocValue(), itemAssoc.getViewType(), itemAssoc.isActive(), itemAssoc.getChangeDate(), itemAssoc.getId()}; argTypes = new int[]{Types.DOUBLE, Types.INTEGER, Types.BOOLEAN, Types.TIMESTAMP, Types.INTEGER}; } else { args = new Object[]{itemAssoc.getAssocValue(), itemAssoc.getViewType(), itemAssoc.getChangeDate(), itemAssoc.getId()}; argTypes = new int[]{Types.DOUBLE, Types.INTEGER, Types.TIMESTAMP, Types.INTEGER};
.getAssocValue())) { // no need to create objects if limit already reached and rule shows worse quality String comment1 = new StringBuilder("conf=").append(String.format("%04f", dh1)).append(" lift=") .append(String.format("%04f", lift)).append(" convic=") .append(tuple.getSupport()).toString(); ItemAssocVO<Integer,Integer> rule = new ItemAssocVO<Integer,Integer>( configuration.getTenantId(), tuple.getItem1(), configuration.getAssocType(), assocValue1 .getAssocValue())) { // no need to create objects if limit already reached and rule shows worse quality .append(tuple.getSupport()).toString(); ItemAssocVO<Integer,Integer> rule = new ItemAssocVO<Integer,Integer>( configuration.getTenantId(), tuple.getItem2(), configuration.getAssocType(), assocValue2
public int insertOrUpdateItemAssocs( List<ItemAssocVO<Integer, String>> typedItemAssocs) { List<ItemAssocVO<Integer,Integer>> itemAssocs = new ArrayList<ItemAssocVO<Integer,Integer>>( typedItemAssocs.size()); for (ItemAssocVO<Integer, String> typedItemAssoc : typedItemAssocs) { itemAssocs.add(typeMappingService.convertTypedItemAssocVO(typedItemAssoc.getTenant(), typedItemAssoc)); } return itemAssocDAO.insertOrUpdateItemAssocs(itemAssocs); }
if (itemAssoc.getId() == null) { if (!itemAssoc.getAssocValue().equals(itemAssocResult.getAssocValue())) { rowsAffected = typedItemAssocDAO.updateItemAssocUsingUniqueKey(itemAssoc);
private void validateAssocValue(ItemAssocVO<Integer,Integer> itemAssoc) { if (itemAssoc.getAssocValue() == null) { throw new IllegalArgumentException("missing constraints, missing 'assocValue', must not be NULL"); } }
private void validateViewType(ItemAssocVO<Integer,Integer> itemAssoc) { if (itemAssoc.getViewType() == null) { throw new IllegalArgumentException("missing constraints, missing 'viewTypeId', must not be NULL"); } }
private void buildTree( DelegateTree<ClusterVO, ItemAssocVO<Integer,Integer>> tree, ClusterVO vertex) { Integer assocTypeCluster = assocTypeDAO.getIdOfType(vertex.getItem().getTenant(), ClusterService.ASSOCTYPE_CLUSTER); List<ItemAssocVO<Integer,Integer>> edges = itemAssocService .getItemAssocs(vertex.getItem(), assocTypeCluster, null, new IAConstraintVO<Integer, Integer>(null, vertex.getItem().getTenant())); for (ItemAssocVO<Integer,Integer> edge : edges) { ItemVO<Integer, Integer> child = edge.getItemTo(); ClusterVO childVertex = loadCluster(child.getTenant(), child.getItem(), child.getType()); if (childVertex != null) { tree.addChild(edge, vertex, childVertex); buildTree(tree, childVertex); } } }
private void validateUniqueKey(ItemAssocVO<Integer,Integer> itemAssoc) { if (itemAssoc.getItemFrom() == null) { throw new IllegalArgumentException( "missing constraints, unique key (tenantId,itemFromId,itemToId,itemFromType,itemToType,assocType,sourceType) must be set, missing 'itemFrom'"); if (itemAssoc.getItemTo() == null) { throw new IllegalArgumentException( "missing constraints, unique key (tenantId,itemFromId,itemToId,itemFromType,itemToType,assocType,sourceType) must be set, missing 'itemTo'"); if (itemAssoc.getItemFrom().getItem() == null) { throw new IllegalArgumentException( "missing constraints, unique key (tenantId,itemFromId,itemToId,itemFromType,itemToType,assocType,sourceType) must be set, missing 'itemFromId'"); if (itemAssoc.getItemFrom().getType() == null) { throw new IllegalArgumentException( "missing constraints, unique key (tenantId,itemFromId,itemToId,itemFromType,itemToType,assocType,sourceType) must be set, missing 'itemFromTypeId'"); if (itemAssoc.getItemTo().getItem() == null) { throw new IllegalArgumentException( "missing constraints, unique key (tenantId,itemFromId,itemToId,itemFromType,itemToType,assocType,sourceType) must be set, missing 'itemToId'"); if (itemAssoc.getItemTo().getType() == null) { throw new IllegalArgumentException( "missing constraints, unique key (tenantId,itemFromId,itemToId,itemFromType,itemToType,assocType,sourceType) must be set, missing 'itemToTypeId'"); if (itemAssoc.getAssocType() == null) { throw new IllegalArgumentException( "missing constraints, unique key (tenantId,itemFromId,itemToId,itemFromType,itemToType,assocType,sourceType) must be set, missing 'assocTypeId'"); if (itemAssoc.getSourceType() == null) {
public int removeAllItemAssocsFromSource(String sourceType, String sourceInfo) { return typedItemAssocDAO.removeItemAssocsQBE( new ItemAssocVO<Integer, String>(null, null, null, null, null, sourceType, sourceInfo, null, null)); }
@Override public int insertItemAssoc(ItemAssocVO<Integer, String> itemAssoc) { Integer tenantId = itemAssoc.getTenant(); if (tenantId == null) { throw new IllegalArgumentException("tenant not specified, can not retrieve type mapping without tenant"); } return itemAssocDAO.insertItemAssoc(typeMappingService.convertTypedItemAssocVO(tenantId, itemAssoc)); }
private void validateAssocValue(ItemAssocVO<Integer,Integer> itemAssoc) { if (itemAssoc.getAssocValue() == null) { throw new IllegalArgumentException("missing constraints, missing 'assocValue', must not be NULL"); } }
private void validateViewType(ItemAssocVO<Integer,Integer> itemAssoc) { if (itemAssoc.getViewType() == null) { throw new IllegalArgumentException("missing constraints, missing 'viewTypeId', must not be NULL"); } }
@Override public ItemAssocVO<Integer,Integer> convertTypedItemAssocVO(Integer tenantId, ItemAssocVO<Integer, String> typedItemAssoc) { if (typedItemAssoc == null) { return null; } return new ItemAssocVO<Integer,Integer>( typedItemAssoc.getId(), typedItemAssoc.getTenant(), convertTypedItemVO(tenantId, typedItemAssoc.getItemFrom()), assocTypeDAO.getIdOfType(tenantId, typedItemAssoc.getAssocType()), typedItemAssoc.getAssocValue(), convertTypedItemVO(tenantId, typedItemAssoc.getItemTo()), sourceTypeDAO.getIdOfType(tenantId, typedItemAssoc.getSourceType()), typedItemAssoc.getSourceInfo(), viewTypeDAO.getIdOfType(tenantId, typedItemAssoc.getViewType()), typedItemAssoc.isActive(), typedItemAssoc.getChangeDate()); }