Skip to content
Permalink
Browse files
[JENKINS-21922] REST API/Remote access API
- Total number of lines, files and languages are exported.
- Number of lines and files are export for each language.
  • Loading branch information
mixalturek committed Mar 14, 2014
1 parent 32b1fa8 commit 4b42fdc0d03cbbc9320c4bc3523d8eba4f4697e3
Showing 3 changed files with 26 additions and 1 deletion.
@@ -1,6 +1,7 @@
package hudson.plugins.sloccount;

import hudson.model.AbstractBuild;
import hudson.model.Api;
import hudson.model.ModelObject;
import hudson.plugins.sloccount.model.File;
import hudson.plugins.sloccount.model.FileFilter;
@@ -147,6 +148,15 @@ public SloccountResult getFolderResult(String jumbledFolder){
return new BreadCrumbResult(filtered, this.owner, folder);
}

/**
* Gets the remote API for the build result.
*
* @return the remote API
*/
public Api getApi() {
return new Api(getStatistics());
}

private static class LanguageFileFilter implements FileFilter, Serializable {
/** Serial version UID. */
private static final long serialVersionUID = 0L;
@@ -2,11 +2,15 @@

import java.io.Serializable;

import org.kohsuke.stapler.export.Exported;
import org.kohsuke.stapler.export.ExportedBean;

/**
* Statistic of one language. The class is thread safe.
*
* @author Michal Turek
*/
@ExportedBean
public class SloccountLanguageStatistics implements Serializable {
/** Serial version UID. */
private static final long serialVersionUID = 0L;
@@ -42,6 +46,7 @@ public SloccountLanguageStatistics(String languageName, int lineCount,
*
* @return the name
*/
@Exported(name="name")
public String getName(){
return name;
}
@@ -51,6 +56,7 @@ public String getName(){
*
* @return the number of lines
*/
@Exported(name="lines")
public int getLineCount(){
return lineCount;
}
@@ -60,6 +66,7 @@ public int getLineCount(){
*
* @return the number of files
*/
@Exported(name="files")
public int getFileCount(){
return fileCount;
}
@@ -8,11 +8,15 @@
import java.util.LinkedList;
import java.util.List;

import org.kohsuke.stapler.export.Exported;
import org.kohsuke.stapler.export.ExportedBean;

/**
* Report statistics. The class is thread safe.
*
* @author Michal Turek
*/
@ExportedBean
public class SloccountReportStatistics implements Serializable {
/** Serial version UID. */
private static final long serialVersionUID = 0L;
@@ -26,14 +30,15 @@ public class SloccountReportStatistics implements Serializable {
* @param statistics the statistics per language
*/
public SloccountReportStatistics(List<SloccountLanguageStatistics> statistics) {
this.statistics = new ArrayList<SloccountLanguageStatistics>(statistics);
this.statistics = new ArrayList<SloccountLanguageStatistics>(statistics);
}

/**
* Get the statistics.
*
* @return the statistics per language
*/
@Exported(name="languages")
public List<SloccountLanguageStatistics> getStatistics() {
return Collections.unmodifiableList(statistics);
}
@@ -43,6 +48,7 @@ public List<SloccountLanguageStatistics> getStatistics() {
*
* @return the lines count
*/
@Exported(name="totalLines")
public int getLineCount() {
int lineCount = 0;

@@ -58,6 +64,7 @@ public int getLineCount() {
*
* @return the files count
*/
@Exported(name="totalFiles")
public int getFileCount() {
int fileCount = 0;

@@ -73,6 +80,7 @@ public int getFileCount() {
*
* @return the languages count
*/
@Exported(name="totalLanguages")
public int getLanguageCount() {
return statistics.size();
}

0 comments on commit 4b42fdc

Please sign in to comment.