Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2117 from recena/JENKINS-31162
[JENKINS-31162] New item categorization
- Loading branch information
Showing
80 changed files
with
1,299 additions
and
506 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
core/src/main/java/jenkins/model/item_category/Categories.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package jenkins.model.item_category; | ||
|
||
import org.kohsuke.accmod.Restricted; | ||
import org.kohsuke.accmod.restrictions.NoExternalUse; | ||
import org.kohsuke.stapler.HttpResponse; | ||
import org.kohsuke.stapler.StaplerRequest; | ||
import org.kohsuke.stapler.StaplerResponse; | ||
import org.kohsuke.stapler.export.Exported; | ||
import org.kohsuke.stapler.export.ExportedBean; | ||
import org.kohsuke.stapler.export.Flavor; | ||
|
||
import javax.annotation.CheckForNull; | ||
import javax.annotation.Nonnull; | ||
import javax.servlet.ServletException; | ||
import java.io.IOException; | ||
import java.io.Serializable; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* It is a logic representation of a set of {@link Category}. | ||
* | ||
* This class is not thread-safe. | ||
*/ | ||
@ExportedBean | ||
@Restricted(NoExternalUse.class) | ||
public class Categories implements HttpResponse, Serializable { | ||
|
||
private List<Category> items; | ||
|
||
public Categories() { | ||
items = new ArrayList<Category>(); | ||
} | ||
|
||
@Exported(name = "categories") | ||
public List<Category> getItems() { | ||
return items; | ||
} | ||
|
||
@Override | ||
public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException { | ||
rsp.serveExposedBean(req, this, Flavor.JSON); | ||
} | ||
|
||
@CheckForNull | ||
public Category getItem(@Nonnull String id) { | ||
for (Category category : items) { | ||
if (category.getId().equals(id)) { | ||
return category; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
} |
73 changes: 73 additions & 0 deletions
73
core/src/main/java/jenkins/model/item_category/Category.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package jenkins.model.item_category; | ||
|
||
import hudson.model.TopLevelItem; | ||
import org.kohsuke.accmod.Restricted; | ||
import org.kohsuke.accmod.restrictions.NoExternalUse; | ||
import org.kohsuke.stapler.export.Exported; | ||
import org.kohsuke.stapler.export.ExportedBean; | ||
|
||
import java.io.Serializable; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* Represents an {@link ItemCategory} and its {@link TopLevelItem}s. | ||
* | ||
* This class is not thread-safe. | ||
*/ | ||
@ExportedBean | ||
@Restricted(NoExternalUse.class) | ||
public class Category implements Serializable { | ||
|
||
private String id; | ||
|
||
private String name; | ||
|
||
private String description; | ||
|
||
private int order; | ||
|
||
private int minToShow; | ||
|
||
private List<Map<String, Serializable>> items; | ||
|
||
public Category(String id, String name, String description, int order, int minToShow, List<Map<String, Serializable>> items) { | ||
this.id= id; | ||
this.name = name; | ||
this.description = description; | ||
this.order = order; | ||
this.minToShow = minToShow; | ||
this.items = items; | ||
} | ||
|
||
@Exported | ||
public String getId() { | ||
return id; | ||
} | ||
|
||
@Exported | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
@Exported | ||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
@Exported | ||
public int getOrder() { | ||
return order; | ||
} | ||
|
||
@Exported | ||
public int getMinToShow() { | ||
return minToShow; | ||
} | ||
|
||
@Exported | ||
public List<Map<String, Serializable>> getItems() { | ||
return items; | ||
} | ||
|
||
} |
Oops, something went wrong.