private Map<String, Map<Integer, Object>> createVersionedRepresentations(final Map<String, FieldData> fields, final Issue issue) { return ImmutableMaps.transformValue(fields, new Function<FieldData, Map<Integer, Object>>() { @Override public Map<Integer, Object> apply(final FieldData fieldData) { // The HashMap is used here because we need to store null values. final Map<Integer, Object> representations = new HashMap<Integer, Object>(); representations.put(FIRST_REPRESENTATION_VERSION, fieldData.getJsonData().getData()); if (!(fieldData.field instanceof CustomField)) { return representations; } final CustomField field = (CustomField) fieldData.field; final CustomFieldType customFieldType = field.getCustomFieldType(); if (!(customFieldType instanceof AbstractCustomFieldType)) { return representations; } final AbstractCustomFieldType abstractCustomFieldType = (AbstractCustomFieldType) customFieldType; final CustomFieldTypeModuleDescriptor descriptor = abstractCustomFieldType.getDescriptor(); representations.putAll(createVersionedRepresentationsForField(field, descriptor, issue)); return representations; } }); }
/** * <p>Produces a relation between {@link com.atlassian.jira.application.ApplicationRole}s and {@link com.atlassian.jira.user.ApplicationUser}s * indicating which users will gain access to which applications if they will be added to given groups.</p> * <p>This method is useful only in seating counting. There is one gotcha: if users are already (or eventually will be) added to some * application, and we want to give them CORE access it's dry-run. We won't count them as jira-core users as it will be implied.</p> * @param users users to be checked * @param groupsToBeAdded groups to be added * @return users grouped by applications in which number of occupied seats should be incremented */ public Map<ApplicationRole, Set<ApplicationUser>> rolesToBeAddedForSeatingCountPurpose(Set<ApplicationUser> users, Set<String> groupsToBeAdded) { final SetMultimap<ApplicationUser, ApplicationRole> userToRoles = HashMultimap.create(); for (ApplicationUser user : users) { userToRoles.putAll(user, calculateRolesToBeAdded(user, groupsToBeAdded)); } return ImmutableMaps.transformValue( Multimaps.invertFrom(userToRoles, HashMultimap.create()).asMap(), ImmutableSet::copyOf ); }