/** * Calculates the next available suffix using a short label - which is * the highest suffix + 1 * * @param shortLabel the label to use * * @return the next available suffix. */ protected static Integer calculateNextSuffix(String shortLabel) { String labelWithoutSuffix = removeSuffix(shortLabel); // we get all the labels with the same bait-prey combination List<String> shortLabelsWithSuffix = IntactContext.getCurrentInstance().getDataContext().getDaoFactory() .getInteractionDao().getShortLabelsLike(labelWithoutSuffix + "%"); int maxSuffix = -1; for (String labelWithSuffix : shortLabelsWithSuffix) { InteractionShortLabel label = new InteractionShortLabel(labelWithSuffix); Integer suffix = label.getSuffix(); if (suffix != null) { maxSuffix = Math.max(maxSuffix, suffix); } else { maxSuffix = 0; } } if (maxSuffix == -1) { return null; } return maxSuffix + 1; }
/** * Calculates the next available suffix using a short label - which is * the highest suffix + 1 * * @param shortLabel the label to use * @return the next available suffix. */ protected static Integer calculateNextSuffix( String shortLabel ) { String labelWithoutSuffix = removeSuffix( shortLabel ); // we get all the labels with the same bait-prey combination List<String> shortLabelsWithSuffix = IntactContext.getCurrentInstance().getDataContext().getDaoFactory() .getInteractionDao().getShortLabelsLike( labelWithoutSuffix + "%" ); int maxSuffix = -1; for ( String labelWithSuffix : shortLabelsWithSuffix ) { InteractionShortLabel label = new InteractionShortLabel( labelWithSuffix ); Integer suffix = label.getSuffix(); if ( suffix != null ) { maxSuffix = Math.max( maxSuffix, suffix ); } else { maxSuffix = 0; } } if ( maxSuffix == -1 ) { return null; } return maxSuffix + 1; }
/** * Calculates the next available suffix using a short label - which is * the highest suffix + 1 * * @param shortLabel the label to use * @return the next available suffix. */ protected static Integer calculateNextSuffix( String shortLabel ) { String labelWithoutSuffix = removeSuffix( shortLabel ); // we get all the labels with the same bait-prey combination List<String> shortLabelsWithSuffix = IntactContext.getCurrentInstance().getDataContext().getDaoFactory() .getInteractionDao().getShortLabelsLike( labelWithoutSuffix + "%" ); int maxSuffix = -1; for ( String labelWithSuffix : shortLabelsWithSuffix ) { InteractionShortLabel label = new InteractionShortLabel( labelWithSuffix ); Integer suffix = label.getSuffix(); if ( suffix != null ) { maxSuffix = Math.max( maxSuffix, suffix ); } else { maxSuffix = 0; } } if ( maxSuffix == -1 ) { return null; } return maxSuffix + 1; }