Skip to content
Permalink
Browse files
[JENKINS-31162] New fields were added to the JSON file
  • Loading branch information
Manuel Recena authored and gusreiber committed Mar 11, 2016
1 parent 31e90f1 commit c0b47318faabeeee7177b3e22de1a8d27ccab578
Showing 3 changed files with 37 additions and 7 deletions.
@@ -50,6 +50,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
@@ -348,15 +349,22 @@ public static Categories getCategories(Authentication a, ItemGroup c) {
boolean found = false;
while (i < categories.getItems().size() && !found) {
if (categories.getItems().get(i).getId() == ic.getId()) {
categories.getItems().get(i).getItems().add(descriptor.clazz.getName());
Map<String, String> metadata = new HashMap<String, String>();
metadata.put("class", descriptor.clazz.getName());
metadata.put("iconClassName", "item-icon-" + descriptor.clazz.getName().substring(descriptor.clazz.getName().lastIndexOf(".") + 1).toLowerCase());
categories.getItems().get(i).getItems().add(metadata);
found = true;
}
i++;
}
if (!found) {
List<String> descriptors = new ArrayList<String>();
descriptors.add(descriptor.clazz.getName());
categories.getItems().add(new Category(ic.getId(), ic.getDisplayName(), ic.getDescription(), ic.getIconClassName(), descriptors));
Map<String, String> metadata = new HashMap<String, String>();
metadata.put("class", descriptor.clazz.getName());
metadata.put("iconClassName", "item-icon-" + descriptor.clazz.getName().substring(descriptor.clazz.getName().lastIndexOf(".") + 1).toLowerCase());
List<Map<String, String>> temp = new ArrayList<Map<String, String>>();
temp.add(metadata);
categories.getItems().add(new Category(ic.getId(), ic.getDisplayName(), ic.getDescription(),
ic.getIconClassName(), ic.getWeight(), temp));
}
}
return categories;
@@ -6,6 +6,7 @@

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
* Represents an {$link ItemCategory} and its {@link TopLevelItem}s.
@@ -21,13 +22,16 @@ public class Category implements Serializable {

private String iconClassName;

private List<String> items;
private int weight;

public Category(String id, String name, String description, String iconClassName, List<String> items) {
private List<Map<String, String>> items;

public Category(String id, String name, String description, String iconClassName, int weight, List<Map<String, String>> items) {
this.id= id;
this.name = name;
this.description = description;
this.iconClassName = iconClassName;
this.weight = weight;
this.items = items;
}

@@ -52,7 +56,12 @@ public String getIconClassName() {
}

@Exported
public List<String> getItems() {
public int getWeight() {
return weight;
}

@Exported
public List<Map<String, String>> getItems() {
return items;
}

@@ -31,6 +31,13 @@ public abstract class ItemCategory implements ModelObject, ExtensionPoint {
*/
public abstract String getDescription();

/**
* Helpful to set the order.
*
* @return the weight
*/
public abstract int getWeight();

/**
* The default category, if an item doesn't belong anywhere else, this is where it goes by default.
*/
@@ -56,6 +63,12 @@ public String getDescription() {
public String getDisplayName() {
return Messages.ItemCategory_Default_DisplayName();
}

@Override
public int getWeight() {
return Integer.MIN_VALUE;
}

}

}

0 comments on commit c0b4731

Please sign in to comment.