Files
github-api/jacoco/org.kohsuke.github/GHProjectCard.java.html
2020-05-31 15:14:45 -07:00

229 lines
8.1 KiB
HTML

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>GHProjectCard.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">GitHub API for Java</a> &gt; <a href="index.source.html" class="el_package">org.kohsuke.github</a> &gt; <span class="el_source">GHProjectCard.java</span></div><h1>GHProjectCard.java</h1><pre class="source lang-java linenums">package org.kohsuke.github;
import org.apache.commons.lang3.StringUtils;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;
import static org.kohsuke.github.Previews.INERTIA;
/**
* The type GHProjectCard.
*
* @author Gunnar Skjold
*/
<span class="fc" id="L16">public class GHProjectCard extends GHObject {</span>
private GitHub root;
private GHProject project;
private GHProjectColumn column;
private String note;
private GHUser creator;
private String content_url, project_url, column_url;
private boolean archived;
public URL getHtmlUrl() throws IOException {
<span class="nc" id="L27"> return null;</span>
}
/**
* Wrap gh project card.
*
* @param root
* the root
* @return the gh project card
*/
public GHProjectCard wrap(GitHub root) {
<span class="fc" id="L38"> this.root = root;</span>
<span class="fc" id="L39"> return this;</span>
}
/**
* Wrap gh project card.
*
* @param column
* the column
* @return the gh project card
*/
public GHProjectCard wrap(GHProjectColumn column) {
<span class="fc" id="L50"> this.column = column;</span>
<span class="fc" id="L51"> this.project = column.project;</span>
<span class="fc" id="L52"> this.root = column.root;</span>
<span class="fc" id="L53"> return this;</span>
}
/**
* Gets root.
*
* @return the root
*/
public GitHub getRoot() {
<span class="nc" id="L62"> return root;</span>
}
/**
* Gets project.
*
* @return the project
* @throws IOException
* the io exception
*/
public GHProject getProject() throws IOException {
<span class="nc bnc" id="L73" title="All 2 branches missed."> if (project == null) {</span>
try {
<span class="nc" id="L75"> project = root.createRequest().withUrlPath(getProjectUrl().getPath()).fetch(GHProject.class).wrap(root);</span>
<span class="nc" id="L76"> } catch (FileNotFoundException e) {</span>
<span class="nc" id="L77"> return null;</span>
<span class="nc" id="L78"> }</span>
}
<span class="nc" id="L80"> return project;</span>
}
/**
* Gets column.
*
* @return the column
* @throws IOException
* the io exception
*/
public GHProjectColumn getColumn() throws IOException {
<span class="nc bnc" id="L91" title="All 2 branches missed."> if (column == null) {</span>
try {
<span class="nc" id="L93"> column = root.createRequest()</span>
<span class="nc" id="L94"> .withUrlPath(getColumnUrl().getPath())</span>
<span class="nc" id="L95"> .fetch(GHProjectColumn.class)</span>
<span class="nc" id="L96"> .wrap(root);</span>
<span class="nc" id="L97"> } catch (FileNotFoundException e) {</span>
<span class="nc" id="L98"> return null;</span>
<span class="nc" id="L99"> }</span>
}
<span class="nc" id="L101"> return column;</span>
}
/**
* Gets content.
*
* @return the content
* @throws IOException
* the io exception
*/
public GHIssue getContent() throws IOException {
<span class="nc bnc" id="L112" title="All 2 branches missed."> if (StringUtils.isEmpty(content_url))</span>
<span class="nc" id="L113"> return null;</span>
try {
<span class="nc bnc" id="L115" title="All 2 branches missed."> if (content_url.contains(&quot;/pulls&quot;)) {</span>
<span class="nc" id="L116"> return root.createRequest()</span>
<span class="nc" id="L117"> .withUrlPath(getContentUrl().getPath())</span>
<span class="nc" id="L118"> .fetch(GHPullRequest.class)</span>
<span class="nc" id="L119"> .wrap(root);</span>
} else {
<span class="nc" id="L121"> return root.createRequest().withUrlPath(getContentUrl().getPath()).fetch(GHIssue.class).wrap(root);</span>
}
<span class="nc" id="L123"> } catch (FileNotFoundException e) {</span>
<span class="nc" id="L124"> return null;</span>
}
}
/**
* Gets note.
*
* @return the note
*/
public String getNote() {
<span class="fc" id="L134"> return note;</span>
}
/**
* Gets creator.
*
* @return the creator
*/
public GHUser getCreator() {
<span class="nc" id="L143"> return creator;</span>
}
/**
* Gets content url.
*
* @return the content url
*/
public URL getContentUrl() {
<span class="fc" id="L152"> return GitHubClient.parseURL(content_url);</span>
}
/**
* Gets project url.
*
* @return the project url
*/
public URL getProjectUrl() {
<span class="nc" id="L161"> return GitHubClient.parseURL(project_url);</span>
}
/**
* Gets column url.
*
* @return the column url
*/
public URL getColumnUrl() {
<span class="nc" id="L170"> return GitHubClient.parseURL(column_url);</span>
}
/**
* Is archived boolean.
*
* @return the boolean
*/
public boolean isArchived() {
<span class="fc" id="L179"> return archived;</span>
}
/**
* Sets note.
*
* @param note
* the note
* @throws IOException
* the io exception
*/
public void setNote(String note) throws IOException {
<span class="fc" id="L191"> edit(&quot;note&quot;, note);</span>
<span class="fc" id="L192"> }</span>
/**
* Sets archived.
*
* @param archived
* the archived
* @throws IOException
* the io exception
*/
public void setArchived(boolean archived) throws IOException {
<span class="fc" id="L203"> edit(&quot;archived&quot;, archived);</span>
<span class="fc" id="L204"> }</span>
private void edit(String key, Object value) throws IOException {
<span class="fc" id="L207"> root.createRequest().method(&quot;PATCH&quot;).withPreview(INERTIA).with(key, value).withUrlPath(getApiRoute()).send();</span>
<span class="fc" id="L208"> }</span>
/**
* Gets api route.
*
* @return the api route
*/
protected String getApiRoute() {
<span class="fc" id="L216"> return String.format(&quot;/projects/columns/cards/%d&quot;, getId());</span>
}
/**
* Delete.
*
* @throws IOException
* the io exception
*/
public void delete() throws IOException {
<span class="fc" id="L226"> root.createRequest().withPreview(INERTIA).method(&quot;DELETE&quot;).withUrlPath(getApiRoute()).send();</span>
<span class="fc" id="L227"> }</span>
}
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.5.201910111838</span></div></body></html>