private static void addIndexCoding(Product product, IndexCoding indexCoding, String indexCodingName) { final IndexCoding targetIndexCoding = new IndexCoding(indexCodingName); targetIndexCoding.setDescription(indexCoding.getDescription()); ProductUtils.copyMetadata(indexCoding, targetIndexCoding); product.getIndexCodingGroup().add(targetIndexCoding); }
protected void addIndexCodingsToProduct(Product product) { final ProductNodeGroup<IndexCoding> indexCodingGroup = getSourceProduct().getIndexCodingGroup(); for (int i = 0; i < indexCodingGroup.getNodeCount(); i++) { IndexCoding sourceIndexCoding = indexCodingGroup.get(i); IndexCoding destIndexCoding = new IndexCoding(sourceIndexCoding.getName()); destIndexCoding.setDescription(sourceIndexCoding.getDescription()); cloneIndexes(sourceIndexCoding, destIndexCoding); product.getIndexCodingGroup().add(destIndexCoding); } }
/** * Copies the given source index coding to the target product * If it exists already, the method simply returns the existing instance. * * @param sourceIndexCoding the source index coding * @param target the target product * * @return The index coding. */ public static IndexCoding copyIndexCoding(IndexCoding sourceIndexCoding, Product target) { IndexCoding indexCoding = target.getIndexCodingGroup().get(sourceIndexCoding.getName()); if (indexCoding == null) { indexCoding = new IndexCoding(sourceIndexCoding.getName()); indexCoding.setDescription(sourceIndexCoding.getDescription()); target.getIndexCodingGroup().add(indexCoding); copyMetadata(sourceIndexCoding, indexCoding); } return indexCoding; }