/* * Copyright (C) 2020 Christian Pierre MOMON * * This file is part of AgirStatool, simple key value database. * * AgirStatool is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * AgirStatool is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with AgirStatool. If not, see . */ package org.april.agirstatool.core; import java.time.LocalDateTime; /** * The Class Projects. */ public class Project { public enum Type { ALONE, CONSOLIDATED, ROOT } private long id; private String identifier; private String name; private String path; private Long parentId; private long childCount; private Projects subProjects; private IssueStats stats; private LocalDateTime lastUpdate; /** * Instantiates a new project. */ public Project(final long id, final String identifier, final String name, final Long parentId) { this.id = id; this.identifier = identifier; setPath(); this.name = name; this.parentId = parentId; this.subProjects = new Projects(); this.childCount = 0; this.stats = new IssueStats(); } public long getChildCount() { return this.childCount; } public long getId() { return this.id; } public String getIdentifier() { return this.identifier; } public LocalDateTime getLastUpdate() { return this.lastUpdate; } public String getName() { return this.name; } public Long getParentId() { return this.parentId; } public String getPath() { return this.path; } /** * Gets the type. * * @return the type */ public Type getType() { Type result; if (this.id == 0) { result = Type.ROOT; } else if (this.name.startsWith("@")) { result = Type.ALONE; } else { result = Type.CONSOLIDATED; } // return result; } /** * Checks for child. * * @return true, if successful */ public boolean hasChild() { boolean result; if (this.childCount > 0) { result = true; } else { result = false; } // return result; } /** * Checks for issue. * * @return true, if successful */ public boolean hasIssue() { boolean result; if (this.issueStats().getCount() == 0) { result = false; } else { result = true; } // return result; } public IssueStats issueStats() { return this.stats; } public void setChildCount(final long childCount) { this.childCount = childCount; } public void setId(final long id) { this.id = id; } public void setIdentifier(final String identifier) { this.identifier = identifier; setPath(); } public void setLastUpdate(final LocalDateTime lastUpdate) { this.lastUpdate = lastUpdate; } public void setName(final String name) { this.name = name; } public void setParentId(final Long parentId) { this.parentId = parentId; } private void setPath() { this.path = this.identifier + ".xhtml"; } public Projects subProjects() { return this.subProjects; } }