show workpackage info for list of projects

This commit is contained in:
Jörg Henke
2026-01-19 15:10:48 +01:00
parent 14c8a5faa8
commit 2cf5a44cf5
4 changed files with 46 additions and 8 deletions

View File

@@ -12,9 +12,12 @@ import java.util.Map;
import org.jooq.DSLContext; import org.jooq.DSLContext;
import org.jooq.DeleteConditionStep; import org.jooq.DeleteConditionStep;
import org.jooq.InsertValuesStep2; import org.jooq.InsertValuesStep2;
import org.jooq.Name;
import org.jooq.Record1; import org.jooq.Record1;
import org.jooq.Record7; import org.jooq.Record7;
import org.jooq.Record8;
import org.jooq.SelectConditionStep; import org.jooq.SelectConditionStep;
import org.jooq.SelectHavingStep;
import org.jooq.impl.DSL; import org.jooq.impl.DSL;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
@@ -31,7 +34,7 @@ import de.jottyfan.timetrack.modules.projectmanagement.model.WorkpackageBean;
*/ */
@Repository @Repository
public class AppRepository { public class AppRepository {
@Autowired @Autowired
private DSLContext jooq; private DSLContext jooq;
@@ -42,7 +45,8 @@ public class AppRepository {
* @return the list of app beans; an empty list at least * @return the list of app beans; an empty list at least
*/ */
public List<AppBean> getAllAppBeans(Integer fkWorkpackage) { public List<AppBean> getAllAppBeans(Integer fkWorkpackage) {
SelectConditionStep<Record7<Integer, Integer, String, String, String, Integer, String>> sql = jooq Name WORKPACKAGES = DSL.name("workpackages");
SelectHavingStep<Record8<Integer, Integer, String, String, String, Integer, String, String[]>> sql = jooq
// @formatter:off // @formatter:off
.select(T_APP.PK_APP, .select(T_APP.PK_APP,
T_APP.FK_BUNDLE, T_APP.FK_BUNDLE,
@@ -50,10 +54,19 @@ public class AppRepository {
T_APP.NAME, T_APP.NAME,
T_APP.DESCRIPTION, T_APP.DESCRIPTION,
T_APP.FK_REPLACED_BY_APP, T_APP.FK_REPLACED_BY_APP,
T_APP.REPOSITORY_URL) T_APP.REPOSITORY_URL,
DSL.arrayAgg(T_WORKPACKAGE.NAME).as(WORKPACKAGES))
.from(T_APP) .from(T_APP)
.leftJoin(T_WORKPACKAGE_APP).on(T_WORKPACKAGE_APP.FK_APP.eq(T_APP.PK_APP)) .leftJoin(T_WORKPACKAGE_APP).on(T_WORKPACKAGE_APP.FK_APP.eq(T_APP.PK_APP))
.where(fkWorkpackage == null ? DSL.trueCondition() : T_WORKPACKAGE_APP.FK_WORKPACKAGE.eq(fkWorkpackage)); .leftJoin(T_WORKPACKAGE).on(T_WORKPACKAGE.PK_WORKPACKAGE.eq(T_WORKPACKAGE_APP.FK_WORKPACKAGE))
.where(fkWorkpackage == null ? DSL.trueCondition() : T_WORKPACKAGE_APP.FK_WORKPACKAGE.eq(fkWorkpackage))
.groupBy(T_APP.PK_APP,
T_APP.FK_BUNDLE,
T_APP.BASIC_FUNCTIONALITY,
T_APP.NAME,
T_APP.DESCRIPTION,
T_APP.FK_REPLACED_BY_APP,
T_APP.REPOSITORY_URL);
// @formatter:on // @formatter:on
return sql.fetchInto(AppBean.class); return sql.fetchInto(AppBean.class);
} }

View File

@@ -17,6 +17,17 @@ public class AppBean implements Serializable {
private String description; private String description;
private Integer fkReplacedByApp; private Integer fkReplacedByApp;
private String repositoryUrl; private String repositoryUrl;
private String[] workpackages;
public String workpackagesString() {
String result = null;
if (workpackages != null) {
for (String s : workpackages) {
result = result == null ? s : String.format("%s, %s", result, s);
}
}
return result;
}
/** /**
* @return the pkApp * @return the pkApp
@@ -115,4 +126,18 @@ public class AppBean implements Serializable {
public void setRepositoryUrl(String repositoryUrl) { public void setRepositoryUrl(String repositoryUrl) {
this.repositoryUrl = repositoryUrl; this.repositoryUrl = repositoryUrl;
} }
/**
* @return the workpackages
*/
public String[] getWorkpackages() {
return workpackages;
}
/**
* @param workpackages the workpackages to set
*/
public void setWorkpackages(String[] workpackages) {
this.workpackages = workpackages;
}
} }

View File

@@ -12,13 +12,13 @@
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col-2">Name</div> <div class="col-2">Name</div>
<div class="col-10" th:text="${app.name}"></div> <div class="col-10 fw-bold" th:text="${app.name}"></div>
<div class="col-2">Beschreibung</div> <div class="col-2">Beschreibung</div>
<div class="col-10" th:text="${app.description}"></div> <div class="col-10" th:text="${app.description}"></div>
<div class="col-2">Basisfunktion</div> <div class="col-2">Basisfunktion</div>
<div class="col-10" th:text="${app.basicFunctionality}"></div> <div class="col-10" th:text="${app.basicFunctionality}"></div>
<div class="col-2">URL der Entwicklung</div> <div class="col-2">URL der Entwicklung</div>
<div class="col-10" th:text="${app.repositoryUrl}"></div> <div class="col-10"><a th:href="${app.repositoryUrl}" target="_blank" th:text="${app.repositoryUrl}"></a></div>
<div class="col-2" th:if="${app.fkReplacedByApp}">Ersetzt durch andere App</div> <div class="col-2" th:if="${app.fkReplacedByApp}">Ersetzt durch andere App</div>
<div class="col-10" th:if="${app.fkReplacedByApp}"> <div class="col-10" th:if="${app.fkReplacedByApp}">
<a th:href="@{/projectmanagement/app/{id}/assign(id=${app.fkReplacedByApp})}" th:text="${app.fkReplacedByApp}"></a> <a th:href="@{/projectmanagement/app/{id}/assign(id=${app.fkReplacedByApp})}" th:text="${app.fkReplacedByApp}"></a>
@@ -28,7 +28,7 @@
<th:block th:with="b=${bundleMap.get(app.fkBundle)}"> <th:block th:with="b=${bundleMap.get(app.fkBundle)}">
<div th:text="${b.name}"></div> <div th:text="${b.name}"></div>
<div th:text="${b.description}"></div> <div th:text="${b.description}"></div>
</h:block> </th:block>
</div> </div>
</div> </div>
<div class="row"> <div class="row">

View File

@@ -26,7 +26,7 @@
<td th:text="${b.name}"></td> <td th:text="${b.name}"></td>
<td th:text="${b.description}"></td> <td th:text="${b.description}"></td>
<td><a th:href="${b.repositoryUrl}" target="_blank">gitlab</a></td> <td><a th:href="${b.repositoryUrl}" target="_blank">gitlab</a></td>
<td><a th:href="@{/projectmanagement/app/{id}/assign(id=${b.pkApp})}">zuordnen</a></td> <td><a th:href="@{/projectmanagement/app/{id}/assign(id=${b.pkApp})}">zuordnen</a><span th:text="' (' + ${b.workpackagesString} + ')'" th:if="${b.workpackagesString}"></span></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>