@Override public String doDefault() throws Exception { if (isFieldLocked()) { return "locked"; } // Set up the context so the view can see it nicely. final FieldConfigScheme configScheme = getConfig(); setGlobal(isGlobalAvailable()); if (configScheme != null) { setName(configScheme.getName()); setDescription(configScheme.getDescription()); // Check if this is still editable in "basic" mode if (configScheme.isBasicMode()) { setBasicMode(true); setGlobal(configScheme.isAllProjects()); final Set issueTypesList = configScheme.getAssociatedIssueTypes(); setIssuetypes(GenericValueUtils.transformToStrings(issueTypesList, "id")); final List projectCategoriesList = configScheme.getAssociatedProjectCategories(); setProjectCategories(GenericValueUtils.transformToLongIds(projectCategoriesList)); final List projectsList = configScheme.getAssociatedProjects(); setProjects(GenericValueUtils.transformToLongIds(projectsList)); // Set the config final MultiMap configMap = configScheme.getConfigsByConfig(); if (configMap == null) { fieldConfigIds = new Long[0]; } else { final Set entries = configScheme.getConfigsByConfig().keySet(); fieldConfigIds = new Long[entries.size()]; int i = 0; for (final Object entry : entries) { final FieldConfig config = (FieldConfig) entry; fieldConfigIds[i] = config.getId(); i++; } } } else { // Complex mode setBasicMode(false); // @TODO } } return super.doDefault(); }
@Override @RequiresXsrfCheck protected String doExecute() throws Exception { // Find all possibly affected issues. final List<GenericValue> associatedProjects = getConfigScheme().getAssociatedProjects(); if ((associatedProjects != null) && !associatedProjects.isEmpty()) { final List<Long> projectIds = GenericValueUtils.transformToLongIdsList(associatedProjects); final Collection<Option> obseleteOptions = CollectionUtils.subtract(getOriginalOptions(), getNewOptions()); if ((obseleteOptions != null) && !obseleteOptions.isEmpty()) { final List<String> obseleteOptionIds = new ArrayList<String>(obseleteOptions.size()); for (final Option option : obseleteOptions) { obseleteOptionIds.add(option.getId()); } final Query query = getQuery(projectIds, obseleteOptionIds); final SearchResults searchResults = searchProvider.search(query, getLoggedInUser(), PagerFilter.getUnlimitedFilter()); final List affectedIssues = searchResults.getIssues(); if ((affectedIssues != null) && !affectedIssues.isEmpty()) { // Prepare for Update configScheme = new FieldConfigScheme.Builder(getConfigScheme()) .setName(getName()) .setDescription(getDescription()) .toFieldConfigScheme(); final List<String> optionIds = new ArrayList<String>(Arrays.asList(getSelectedOptions())); return migrateIssues(this, affectedIssues, optionIds); } } } return super.doExecute(); }