Thu, 15 Oct 2020 12:27:05 +0200
adds component entity
1.1 --- a/setup/postgres/psql_create_tables.sql Thu Oct 15 11:42:43 2020 +0200 1.2 +++ b/setup/postgres/psql_create_tables.sql Thu Oct 15 12:27:05 2020 +0200 1.3 @@ -33,6 +33,16 @@ 1.4 status version_status not null default 'Future' 1.5 ); 1.6 1.7 + 1.8 +create table lpit_component ( 1.9 + id serial primary key, 1.10 + project integer not null references lpit_project(projectid), 1.11 + name varchar(20) not null, 1.12 + color char(6) not null default '000000', 1.13 + ordinal integer not null default 0, 1.14 + description text 1.15 +); 1.16 + 1.17 create type issue_status as enum ( 1.18 'InSpecification', 1.19 'ToDo', 1.20 @@ -61,6 +71,7 @@ 1.21 create table lpit_issue ( 1.22 issueid serial primary key, 1.23 project integer not null references lpit_project(projectid), 1.24 + component integer references lpit_component(id), 1.25 status issue_status not null default 'InSpecification', 1.26 category issue_category not null default 'Feature', 1.27 subject varchar(200) not null,
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/src/main/java/de/uapcore/lightpit/entities/Component.java Thu Oct 15 12:27:05 2020 +0200 2.3 @@ -0,0 +1,113 @@ 2.4 +/* 2.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 2.6 + * 2.7 + * Copyright 2020 Mike Becker. All rights reserved. 2.8 + * 2.9 + * Redistribution and use in source and binary forms, with or without 2.10 + * modification, are permitted provided that the following conditions are met: 2.11 + * 2.12 + * 1. Redistributions of source code must retain the above copyright 2.13 + * notice, this list of conditions and the following disclaimer. 2.14 + * 2.15 + * 2. Redistributions in binary form must reproduce the above copyright 2.16 + * notice, this list of conditions and the following disclaimer in the 2.17 + * documentation and/or other materials provided with the distribution. 2.18 + * 2.19 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 2.20 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2.21 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2.22 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 2.23 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2.24 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2.25 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2.26 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2.27 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2.28 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 2.29 + * POSSIBILITY OF SUCH DAMAGE. 2.30 + * 2.31 + */ 2.32 +package de.uapcore.lightpit.entities; 2.33 + 2.34 +import de.uapcore.lightpit.types.WebColor; 2.35 + 2.36 +import java.util.Objects; 2.37 + 2.38 +public final class Component { 2.39 + 2.40 + private final int id; 2.41 + 2.42 + private String name; 2.43 + 2.44 + private WebColor color; 2.45 + 2.46 + private int ordinal = 0; 2.47 + 2.48 + private String description = null; 2.49 + 2.50 + private User lead = null; 2.51 + 2.52 + /** 2.53 + * Sole constructor. 2.54 + * @param id the ID of the component 2.55 + */ 2.56 + public Component(int id) { 2.57 + this.id = id; 2.58 + } 2.59 + 2.60 + public int getId() { 2.61 + return id; 2.62 + } 2.63 + 2.64 + public String getName() { 2.65 + return name; 2.66 + } 2.67 + 2.68 + public void setName(String name) { 2.69 + this.name = name; 2.70 + } 2.71 + 2.72 + public WebColor getColor() { 2.73 + return color; 2.74 + } 2.75 + 2.76 + public void setColor(WebColor color) { 2.77 + this.color = color; 2.78 + } 2.79 + 2.80 + public int getOrdinal() { 2.81 + return ordinal; 2.82 + } 2.83 + 2.84 + public void setOrdinal(int ordinal) { 2.85 + this.ordinal = ordinal; 2.86 + } 2.87 + 2.88 + public String getDescription() { 2.89 + return description; 2.90 + } 2.91 + 2.92 + public void setDescription(String description) { 2.93 + this.description = description; 2.94 + } 2.95 + 2.96 + public User getLead() { 2.97 + return lead; 2.98 + } 2.99 + 2.100 + public void setLead(User lead) { 2.101 + this.lead = lead; 2.102 + } 2.103 + 2.104 + @Override 2.105 + public boolean equals(Object o) { 2.106 + if (this == o) return true; 2.107 + if (o == null || getClass() != o.getClass()) return false; 2.108 + Component component = (Component) o; 2.109 + return id == component.id; 2.110 + } 2.111 + 2.112 + @Override 2.113 + public int hashCode() { 2.114 + return Objects.hash(id); 2.115 + } 2.116 +}
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/src/main/java/de/uapcore/lightpit/types/WebColor.java Thu Oct 15 12:27:05 2020 +0200 3.3 @@ -0,0 +1,30 @@ 3.4 +package de.uapcore.lightpit.types; 3.5 + 3.6 +public final class WebColor { 3.7 + 3.8 + private final String hex; 3.9 + 3.10 + /** 3.11 + * Constructs a color object from a hex string. 3.12 + * @param hex the 6 digits hex string optionally preceded by a hash symbol 3.13 + * @throws IllegalArgumentException if the given string does not specify a color 3.14 + */ 3.15 + public WebColor(String hex) throws IllegalArgumentException { 3.16 + this.hex = (hex.startsWith("#") ? hex : ("#"+hex)).toUpperCase(); 3.17 + if (!this.hex.matches("#[0-9A-F]{6}")) 3.18 + throw new IllegalArgumentException(hex+" is not a color"); 3.19 + } 3.20 + 3.21 + /** 3.22 + * Returns the hex representation without th leading hash symbol. 3.23 + * @return the hex representation of this color (e.g. FF0000 for red) 3.24 + */ 3.25 + public String getHex() { 3.26 + return hex.substring(1); 3.27 + } 3.28 + 3.29 + @Override 3.30 + public String toString() { 3.31 + return hex; 3.32 + } 3.33 +}