This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<?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="de"><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>Task.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">GSE2TaskTracker</a> > <a href="index.source.html" class="el_package">hhn.temp.project</a> > <span class="el_source">Task.java</span></div><h1>Task.java</h1><pre class="source lang-java linenums">package hhn.temp.project;
|
||||
|
||||
import hhn.temp.project.expections.TaskHasNoWorkerException;
|
||||
import hhn.temp.project.provider.MySql;
|
||||
|
||||
public class Task {
|
||||
|
||||
@@ -8,82 +9,87 @@ public class Task {
|
||||
private String description;
|
||||
private TaskStatus taskStatus;
|
||||
private int taskID;
|
||||
<span class="fc" id="L11"> private static int idCounter = 0;</span>
|
||||
private String workername;
|
||||
private MySql mySql;
|
||||
|
||||
<span class="fc" id="L14"> public Task(String name, String description) {</span>
|
||||
<span class="fc" id="L15"> public Task(int id, String name, String description, String workername, TaskStatus status, MySql mySql) {</span>
|
||||
|
||||
|
||||
<span class="fc" id="L17"> this.name = name;</span>
|
||||
<span class="fc" id="L18"> this.description = description;</span>
|
||||
<span class="fc" id="L19"> this.taskStatus = TaskStatus.OPEN;</span>
|
||||
//TODO when DB then auto IDs
|
||||
<span class="fc" id="L21"> this.taskID = idCounter++;</span>
|
||||
<span class="fc" id="L22"> }</span>
|
||||
<span class="fc" id="L17"> this.taskID = id;</span>
|
||||
<span class="fc" id="L18"> this.name = name;</span>
|
||||
<span class="fc" id="L19"> this.description = description;</span>
|
||||
<span class="fc" id="L20"> this.taskStatus = status;</span>
|
||||
<span class="fc" id="L21"> this.workername = workername;</span>
|
||||
<span class="fc" id="L22"> this.mySql = mySql;</span>
|
||||
<span class="fc" id="L23"> }</span>
|
||||
|
||||
public int getTaskID() {
|
||||
<span class="fc" id="L25"> return this.taskID;</span>
|
||||
<span class="fc" id="L26"> return this.taskID;</span>
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
<span class="fc" id="L29"> return this.name;</span>
|
||||
<span class="fc" id="L30"> return this.name;</span>
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
<span class="fc" id="L33"> return description;</span>
|
||||
<span class="fc" id="L34"> return description;</span>
|
||||
}
|
||||
|
||||
public TaskStatus getStatus() {
|
||||
<span class="fc" id="L37"> return taskStatus;</span>
|
||||
<span class="fc" id="L38"> return taskStatus;</span>
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
<span class="fc bfc" id="L41" title="All 2 branches covered."> if (description == null ) {</span>
|
||||
<span class="fc bfc" id="L42" title="All 2 branches covered."> if (description == null ) {</span>
|
||||
|
||||
<span class="fc" id="L43"> throw new IllegalArgumentException("Description is null!");</span>
|
||||
<span class="fc" id="L44"> throw new IllegalArgumentException("Description is null!");</span>
|
||||
}
|
||||
|
||||
<span class="fc" id="L46"> this.description = description;</span>
|
||||
<span class="fc" id="L47"> }</span>
|
||||
<span class="fc" id="L47"> this.mySql.updateDescription(taskID, description);</span>
|
||||
<span class="fc" id="L48"> this.description = description;</span>
|
||||
<span class="fc" id="L49"> }</span>
|
||||
|
||||
public void setStatus(TaskStatus taskStatus) {
|
||||
<span class="fc bfc" id="L50" title="All 2 branches covered."> if (taskStatus == null ) {</span>
|
||||
<span class="fc bfc" id="L52" title="All 2 branches covered."> if (taskStatus == null ) {</span>
|
||||
|
||||
<span class="fc" id="L52"> throw new IllegalArgumentException("TaskStatus is null!");</span>
|
||||
<span class="fc" id="L54"> throw new IllegalArgumentException("TaskStatus is null!");</span>
|
||||
}
|
||||
|
||||
<span class="fc" id="L55"> this.taskStatus = taskStatus;</span>
|
||||
<span class="fc" id="L56"> }</span>
|
||||
<span class="fc" id="L57"> this.mySql.updateStatus(taskID, taskStatus);</span>
|
||||
<span class="fc" id="L58"> this.taskStatus = taskStatus;</span>
|
||||
<span class="fc" id="L59"> }</span>
|
||||
|
||||
public void setWorker(String workerName) {
|
||||
<span class="fc bfc" id="L59" title="All 4 branches covered."> if(workerName == null || workerName.isEmpty()) {</span>
|
||||
<span class="fc" id="L60"> throw new IllegalArgumentException("There is nothing in this variable.");</span>
|
||||
<span class="fc bfc" id="L62" title="All 4 branches covered."> if(workerName == null || workerName.isEmpty()) {</span>
|
||||
<span class="fc" id="L63"> throw new IllegalArgumentException("There is nothing in this variable.");</span>
|
||||
}
|
||||
<span class="fc bfc" id="L62" title="All 2 branches covered."> if(!checkOnlyLetter(workerName)){</span>
|
||||
<span class="fc" id="L63"> throw new IllegalArgumentException("Only Lettery as Worker Name!");</span>
|
||||
<span class="fc bfc" id="L65" title="All 2 branches covered."> if(!checkOnlyLetter(workerName)){</span>
|
||||
<span class="fc" id="L66"> throw new IllegalArgumentException("Only Lettery as Worker Name!");</span>
|
||||
}
|
||||
<span class="fc" id="L65"> this.workername = workerName;</span>
|
||||
<span class="fc" id="L66"> this.setStatus(TaskStatus.INPROCESS);</span>
|
||||
<span class="fc" id="L67"> }</span>
|
||||
|
||||
<span class="fc" id="L69"> this.mySql.updateStatus(taskID, TaskStatus.INPROCESS);</span>
|
||||
<span class="fc" id="L70"> this.mySql.updateWorker(taskID, workerName);</span>
|
||||
<span class="fc" id="L71"> this.workername = workerName;</span>
|
||||
<span class="fc" id="L72"> this.setStatus(TaskStatus.INPROCESS);</span>
|
||||
<span class="fc" id="L73"> }</span>
|
||||
|
||||
public String getWorker() {
|
||||
<span class="fc bfc" id="L70" title="All 2 branches covered."> if(this.workername == null) {</span>
|
||||
<span class="fc" id="L71"> throw new TaskHasNoWorkerException("Please set first a Worker");</span>
|
||||
<span class="fc bfc" id="L76" title="All 2 branches covered."> if(this.workername == null) {</span>
|
||||
<span class="fc" id="L77"> throw new TaskHasNoWorkerException("Please set first a Worker");</span>
|
||||
}
|
||||
<span class="fc" id="L73"> return this.workername;</span>
|
||||
<span class="fc" id="L79"> return this.workername;</span>
|
||||
}
|
||||
|
||||
private boolean checkOnlyLetter(String text) {
|
||||
<span class="fc" id="L77"> boolean result = true;</span>
|
||||
<span class="fc" id="L83"> boolean result = true;</span>
|
||||
|
||||
<span class="fc bfc" id="L79" title="All 2 branches covered."> for(int i = 0; i < text.length(); i++) {</span>
|
||||
<span class="fc" id="L80"> char c = text.charAt(i);</span>
|
||||
<span class="fc bfc" id="L81" title="All 2 branches covered."> if(!Character.isLetter(c)) {</span>
|
||||
<span class="fc" id="L82"> result = false;</span>
|
||||
<span class="fc" id="L83"> break;</span>
|
||||
<span class="fc bfc" id="L85" title="All 2 branches covered."> for(int i = 0; i < text.length(); i++) {</span>
|
||||
<span class="fc" id="L86"> char c = text.charAt(i);</span>
|
||||
<span class="fc bfc" id="L87" title="All 2 branches covered."> if(!Character.isLetter(c)) {</span>
|
||||
<span class="fc" id="L88"> result = false;</span>
|
||||
<span class="fc" id="L89"> break;</span>
|
||||
}
|
||||
}
|
||||
<span class="fc" id="L86"> return result;</span>
|
||||
<span class="fc" id="L92"> return result;</span>
|
||||
}
|
||||
}
|
||||
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.13.202504020838</span></div></body></html>
|
||||
Reference in New Issue
Block a user