From b46cb4de8a4f1cdde515d0d913337ca72b2a1aa8 Mon Sep 17 00:00:00 2001 From: Markus Herpich Date: Tue, 2 Apr 2019 13:56:45 +0200 Subject: [PATCH] feat(report): add common rules table Add and fill the common rules table in the report. Therefore use Todo to hold the actual common rule - project level obligation. Signed-off-by: Markus Herpich --- .../summary/ProjectSummaryTest.java | 3 + .../outputGenerators/DocxGenerator.java | 18 ++++- .../src/main/resources/templateReport.docx | Bin 11329 -> 11581 bytes .../sw360/portal/common/PortalConstants.java | 1 + .../portal/portlets/admin/VendorPortlet.java | 2 +- .../moderation/ModerationPortlet.java | 11 --- .../portlets/projects/ProjectPortlet.java | 39 +++++++---- .../projects/ProjectPortletUtils.java | 42 ++++++++++++ .../includes/projects/administration.jspf | 20 ++++++ .../includes/projects/administrationEdit.jspf | 20 ++++++ .../sw360/datahandler/common/SW360Utils.java | 64 +++++++++++++++++- .../src/main/thrift/licenses.thrift | 3 + .../src/main/thrift/projects.thrift | 11 ++- .../core/JacksonCustomizations.java | 2 + 14 files changed, 209 insertions(+), 27 deletions(-) diff --git a/backend/src-common/src/test/java/org/eclipse/sw360/components/summary/ProjectSummaryTest.java b/backend/src-common/src/test/java/org/eclipse/sw360/components/summary/ProjectSummaryTest.java index 470067c8cd..9c8808b462 100644 --- a/backend/src-common/src/test/java/org/eclipse/sw360/components/summary/ProjectSummaryTest.java +++ b/backend/src-common/src/test/java/org/eclipse/sw360/components/summary/ProjectSummaryTest.java @@ -81,6 +81,9 @@ public void testAllRequiredFieldsAreSet() throws Exception { case ENABLE_VULNERABILITIES_DISPLAY: project.enableVulnerabilitiesDisplay = true; break; + case TODOS: + project.todos = Collections.emptySet(); + break; default: //most fields are string project.setFieldValue(renderedField, "asd"); break; diff --git a/backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/DocxGenerator.java b/backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/DocxGenerator.java index 3d362bb7f2..63dd39e41c 100644 --- a/backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/DocxGenerator.java +++ b/backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/DocxGenerator.java @@ -17,6 +17,7 @@ import org.apache.thrift.TException; import org.apache.xmlbeans.XmlException; import org.eclipse.sw360.datahandler.common.CommonUtils; +import org.eclipse.sw360.datahandler.common.SW360Utils; import org.eclipse.sw360.datahandler.thrift.SW360Exception; import org.eclipse.sw360.datahandler.thrift.ThriftClients; import org.eclipse.sw360.datahandler.thrift.components.Component; @@ -54,8 +55,9 @@ public class DocxGenerator extends OutputGenerator { private static final String DOCX_OUTPUT_TYPE = "docx"; public static final String UNKNOWN_LICENSE = "Unknown"; private static final long ADDITIONAL_REQ_THRESHOLD = 3; - public static final int ADDITIONAL_REQ_TABLE_INDEX = 4; + public static final int ADDITIONAL_REQ_TABLE_INDEX = 5; public static final int DEV_DETAIL_TABLE_INDEX = 2; + private static final int COMMON_RULES_TABLE_INDEX = 4; public DocxGenerator(OutputFormatVariant outputFormatVariant, String description) { super(DOCX_OUTPUT_TYPE, description, true, DOCX_MIME_TYPE, outputFormatVariant); @@ -175,6 +177,7 @@ private void fillReportDocument( fillSpecialOSSRisksTable(document, project, obligationResults); fillDevelopmentDetailsTable(document, project, user); fillOverview3rdPartyComponentTable(document, projectLicenseInfoResults); + fillCommonRulesTable(document, project); fillAdditionalRequirementsTable(document, obligationResults); // because of the impossible API component subsections must be the last thing in the docx file @@ -551,4 +554,17 @@ private void fillLicenseList(XWPFDocument document, Collection { + currentRow[0] = currentRow[0] + 1; + XWPFTableRow row = table.insertNewTableRow(currentRow[0]); + row.addNewTableCell().setText(todo.getKey().getText()); + row.addNewTableCell().setText(todo.getValue().fulfilled ? "yes" : "no"); + }); + } } diff --git a/backend/src/src-licenseinfo/src/main/resources/templateReport.docx b/backend/src/src-licenseinfo/src/main/resources/templateReport.docx index bf891ef167d25015bd98e5e825b1e98c5cd4f424..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3?zNbmoI<~h1U-Gu#=URWOYjdEzEwwrxU!9+WaJ#Mh z@O)ROq`nQ=XUNvlrX_BD4NHVg@WsN#1qN@07=n`TDTZK;C2h8EtC=3}y$csyCwr0< z-cc{l*>OojTEF1Ml2(zIx!MZGSD!|*riyi$ZL;Up-qvQwhDJg?L6(OG^ia(I9w6=L z-pQQL7`X)S)7s8sJcp4MiOdJ6;^i`$1yYCR+rTpt=P?q)MfNjBj>Aa*VvHQblGw(Q z#SM2P1>+*Gz=y5COYn7>@_krWa^6*<^ur|$z(rn%4_k+q;O{c!|3Ini%&1HmjY}G< z5x#{NwuJ}T6LO60dD|U;jI)B_hGD>;2xrisQAFQ_df*&YI z)gQZxj?11(^?&HzyL=X2UbWTLZ^DvgKt+4s61s`8S?T9ihv|o(o=NGlsk(Yn^TGhyGq+ z%bmO5G2RoHkaus?+^h1A@TnxO3F|aS^~H~NH-`AL)c&Csfsc7 zuks|q%=_xMM){xIQql)zPKrMyeI9NmI;}f39inAmlpxtxAUj07(D71VERB z1qA*{^oamTU`&$qfPY#1y>$M&SG%N7K*~QY+JPjnJ%mZ$f#iQq?|(b6PkPNl0r}%t zf4?T?zisL8`vmWuTrJq$+`Szv-PpVw9aKRuuy}xfGBe6|H_+?l--JynBLMKbe*bN} zQ2)ai?BQr;>1qqM{@?aSY|1g;jKUOtvpyOK|LK63{vQskoWSmyre+S7|JwnZGAZcW cvGQ;Gt>5;zf7>1aC}c>&VWmUlX8J?=Kg_t`;{X5v diff --git a/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/common/PortalConstants.java b/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/common/PortalConstants.java index 3343fffe62..0a508ad38f 100644 --- a/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/common/PortalConstants.java +++ b/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/common/PortalConstants.java @@ -162,6 +162,7 @@ public class PortalConstants { public static final String DEFAULT_OBLIGATIONS_TEXT = "defaultObligationsText"; public static final String DEFAULT_LICENSE_INFO_HEADER_TEXT_FOR_DISPALY = "--default text--"; public static final String DEFAULT_OBLIGATIONS_TEXT_FOR_DISPALY = "--default text--"; + public static final String PROJECT_OBLIGATIONS = "projectObligations"; public static final Set PROJECT_EXTERNAL_ID_KEYS; public static final String PROJECT_SELECTED_ATTACHMENT_USAGES = "selectedAttachmentUsages"; public static final String PROJECT_SELECTED_ATTACHMENT_USAGES_SHADOWS = "selectedAttachmentUsagesShadows"; diff --git a/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/portlets/admin/VendorPortlet.java b/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/portlets/admin/VendorPortlet.java index b907594247..70b354953a 100644 --- a/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/portlets/admin/VendorPortlet.java +++ b/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/portlets/admin/VendorPortlet.java @@ -147,7 +147,7 @@ public void updateVendor(ActionRequest request, ActionResponse response) throws RequestStatus requestStatus = vendorClient.updateVendor(vendor, user); setSessionMessage(request, requestStatus, "Vendor", "update", vendor.getShortname()); } catch (TException e) { - log.error("Error fetching release from backend!", e); + log.error("Error fetching vendor from backend!", e); } } else{ diff --git a/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/portlets/moderation/ModerationPortlet.java b/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/portlets/moderation/ModerationPortlet.java index a0d92782d9..48e23ee2c5 100644 --- a/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/portlets/moderation/ModerationPortlet.java +++ b/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/portlets/moderation/ModerationPortlet.java @@ -493,7 +493,6 @@ public void renderProjectModeration(RenderRequest request, RenderResponse respon is_used = client.projectIsUsed(actual_project.getId()); request.setAttribute(PortalConstants.ACTUAL_PROJECT, actual_project); request.setAttribute(PortalConstants.DEFAULT_LICENSE_INFO_HEADER_TEXT, getDefaultLicenseInfoHeaderText()); - request.setAttribute(PortalConstants.DEFAULT_OBLIGATIONS_TEXT, getDefaultObligationsText()); } catch (TException e) { log.error("Could not retrieve project", e); } @@ -603,14 +602,4 @@ private String getDefaultLicenseInfoHeaderText() { return ""; } } - - private String getDefaultObligationsText() { - final LicenseInfoService.Iface licenseInfoClient = thriftClients.makeLicenseInfoClient(); - try { - return licenseInfoClient.getDefaultObligationsText(); - } catch (TException e) { - log.error("Could not load default clearing summary text from backend.", e); - return ""; - } - } } diff --git a/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/portlets/projects/ProjectPortlet.java b/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/portlets/projects/ProjectPortlet.java index 80515e0b04..fa4b61bcc2 100644 --- a/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/portlets/projects/ProjectPortlet.java +++ b/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/portlets/projects/ProjectPortlet.java @@ -14,19 +14,32 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Strings; import com.google.common.collect.*; -import com.liferay.portal.kernel.json.*; +import com.liferay.portal.kernel.json.JSONArray; +import com.liferay.portal.kernel.json.JSONException; +import com.liferay.portal.kernel.json.JSONFactoryUtil; +import com.liferay.portal.kernel.json.JSONObject; import com.liferay.portal.kernel.portlet.PortletResponseUtil; import com.liferay.portal.kernel.servlet.SessionMessages; import com.liferay.portal.model.Organization; import com.liferay.portal.util.PortalUtil; - -import org.eclipse.sw360.datahandler.common.*; +import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; +import org.apache.thrift.TException; +import org.apache.thrift.TSerializer; +import org.apache.thrift.protocol.TSimpleJSONProtocol; +import org.eclipse.sw360.datahandler.common.CommonUtils; +import org.eclipse.sw360.datahandler.common.SW360Constants; +import org.eclipse.sw360.datahandler.common.SW360Utils; +import org.eclipse.sw360.datahandler.common.ThriftEnumUtils; import org.eclipse.sw360.datahandler.common.WrappedException.WrappedTException; import org.eclipse.sw360.datahandler.couchdb.lucene.LuceneAwareDatabaseConnector; import org.eclipse.sw360.datahandler.permissions.PermissionUtils; import org.eclipse.sw360.datahandler.thrift.*; import org.eclipse.sw360.datahandler.thrift.attachments.*; -import org.eclipse.sw360.datahandler.thrift.components.*; +import org.eclipse.sw360.datahandler.thrift.components.ComponentService; +import org.eclipse.sw360.datahandler.thrift.components.Release; +import org.eclipse.sw360.datahandler.thrift.components.ReleaseClearingStatusData; +import org.eclipse.sw360.datahandler.thrift.components.ReleaseLink; import org.eclipse.sw360.datahandler.thrift.cvesearch.CveSearchService; import org.eclipse.sw360.datahandler.thrift.cvesearch.VulnerabilityUpdateStatus; import org.eclipse.sw360.datahandler.thrift.licenseinfo.*; @@ -44,24 +57,20 @@ import org.eclipse.sw360.portal.users.LifeRayUserSession; import org.eclipse.sw360.portal.users.UserCacheHolder; import org.eclipse.sw360.portal.users.UserUtils; - -import org.apache.commons.lang.StringUtils; -import org.apache.log4j.Logger; -import org.apache.thrift.TException; -import org.apache.thrift.TSerializer; -import org.apache.thrift.protocol.TSimpleJSONProtocol; import org.jetbrains.annotations.NotNull; import javax.portlet.*; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; - import java.io.IOException; import java.io.PrintWriter; import java.net.URLConnection; import java.util.*; import java.util.Map.Entry; -import java.util.function.*; +import java.util.function.BiConsumer; +import java.util.function.BiFunction; +import java.util.function.Function; +import java.util.function.Predicate; import java.util.stream.Collector; import java.util.stream.Collectors; @@ -837,6 +846,7 @@ private void prepareDetailView(RenderRequest request, RenderResponse response) t request.setAttribute(DOCUMENT_TYPE, SW360Constants.TYPE_PROJECT); request.setAttribute(DOCUMENT_ID, id); request.setAttribute(DEFAULT_LICENSE_INFO_HEADER_TEXT, getProjectDefaultLicenseInfoHeaderText()); + request.setAttribute(DEFAULT_OBLIGATIONS_TEXT, getProjectDefaultObligationsText()); if (id != null) { try { @@ -860,6 +870,7 @@ private void prepareDetailView(RenderRequest request, RenderResponse response) t PermissionUtils.makePermission(project, user).isActionAllowed(RequestedAction.WRITE)); addProjectBreadcrumb(request, response, project); + request.setAttribute(PROJECT_OBLIGATIONS, SW360Utils.getProjectObligations(project)); } catch (TException e) { log.error("Error fetching project from backend!", e); @@ -1076,6 +1087,7 @@ private void prepareProjectEdit(RenderRequest request) { request.setAttribute(PROJECT, project); request.setAttribute(DOCUMENT_ID, id); + request.setAttribute(PROJECT_OBLIGATIONS, SW360Utils.getProjectObligations(project)); setAttachmentsInRequest(request, project); try { @@ -1106,6 +1118,7 @@ private void prepareProjectEdit(RenderRequest request) { } request.setAttribute(USING_PROJECTS, Collections.emptySet()); request.setAttribute(ALL_USING_PROJECTS_COUNT, 0); + request.setAttribute(PROJECT_OBLIGATIONS, SW360Utils.getProjectObligations(project)); SessionMessages.add(request, "request_processed", "New Project"); } @@ -1284,6 +1297,8 @@ private String getProjectDefaultObligationsText() { } } + + private void serveProjectList(ResourceRequest request, ResourceResponse response) throws IOException, PortletException { HttpServletRequest originalServletRequest = PortalUtil.getOriginalServletRequest(PortalUtil.getHttpServletRequest(request)); PaginationParameters paginationParameters = PaginationParser.parametersFrom(originalServletRequest); diff --git a/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/portlets/projects/ProjectPortletUtils.java b/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/portlets/projects/ProjectPortletUtils.java index cf0a69a400..69b3edc318 100644 --- a/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/portlets/projects/ProjectPortletUtils.java +++ b/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/portlets/projects/ProjectPortletUtils.java @@ -24,6 +24,7 @@ import org.eclipse.sw360.datahandler.thrift.projects.Project; import org.eclipse.sw360.datahandler.thrift.projects.ProjectLink; import org.eclipse.sw360.datahandler.thrift.projects.ProjectRelationship; +import org.eclipse.sw360.datahandler.thrift.projects.ProjectTodo; import org.eclipse.sw360.datahandler.thrift.users.User; import org.eclipse.sw360.datahandler.thrift.vulnerabilities.ProjectVulnerabilityRating; import org.eclipse.sw360.datahandler.thrift.vulnerabilities.VulnerabilityCheckStatus; @@ -107,12 +108,53 @@ public static void updateProjectFromRequest(PortletRequest request, Project proj case EXTERNAL_IDS: project.setExternalIds(PortletUtils.getExternalIdMapFromRequest(request)); break; + case TODOS: + String userId = UserCacheHolder.getUserFromRequest(request).getId(); + updateProjectTodosFromRequest(request.getParameterValues(field.toString()), userId, project); + break; default: setFieldValue(request, project, field); } } } + private static void updateProjectTodosFromRequest(String[] ids, String userId, Project project) { + Set idSet = ids != null ? Arrays.stream(ids).collect(Collectors.toSet()) : Collections.emptySet(); + Set currentTodos = project.getTodosSize() > 0 ? project.getTodos() : Collections.emptySet(); + String updated = SW360Utils.getCreatedOnTime(); + + // assemble set of project todos + Set projectTodos = idSet.stream() + .map(id -> currentTodos.stream() + .filter(pt -> pt.getTodoId().equals(id)) + .findAny() + .orElseGet(() -> new ProjectTodo(id, userId, updated, true))) + .collect(Collectors.toSet()); + + // update changed to fulfilled + projectTodos.stream() + .filter(projectTodo -> !projectTodo.fulfilled) + .forEach(projectTodo -> { + projectTodo.fulfilled = true; + projectTodo.setUserId(userId); + projectTodo.setUpdated(updated); + }); + + // update changed to not fulfilled + Set changedToNotFulfilled = currentTodos.stream() + .filter(projectTodo -> idSet.stream().noneMatch(id -> id.equals(projectTodo.todoId))) + .map(projectTodo -> { + projectTodo.fulfilled = false; + projectTodo.setUserId(userId); + projectTodo.setUpdated(updated); + return projectTodo; + }) + .collect(Collectors.toSet()); + + projectTodos.addAll(changedToNotFulfilled); + project.setTodos(projectTodos); + } + private static void updateLinkedReleasesFromRequest(PortletRequest request, Map releaseUsage) { releaseUsage.clear(); String[] ids = request.getParameterValues(Project._Fields.RELEASE_ID_TO_USAGE.toString() + ReleaseLink._Fields.ID.toString()); diff --git a/frontend/sw360-portlet/src/main/webapp/html/projects/includes/projects/administration.jspf b/frontend/sw360-portlet/src/main/webapp/html/projects/includes/projects/administration.jspf index cb42757937..a6712b26ce 100644 --- a/frontend/sw360-portlet/src/main/webapp/html/projects/includes/projects/administration.jspf +++ b/frontend/sw360-portlet/src/main/webapp/html/projects/includes/projects/administration.jspf @@ -9,6 +9,8 @@ ~ http://www.eclipse.org/legal/epl-v10.html --%> +<%@ taglib prefix="core_rt" uri="http://java.sun.com/jstl/core_rt" %> + @@ -96,6 +98,24 @@
+ + + + + + + + + + + + + +
ObligationFulfilledModified
${entry.getKey().getText()}checked="checked" + />${entry.getValue().getModificationHint()}
+ diff --git a/frontend/sw360-portlet/src/main/webapp/html/projects/includes/projects/administrationEdit.jspf b/frontend/sw360-portlet/src/main/webapp/html/projects/includes/projects/administrationEdit.jspf index 8483afb7d3..58fe525fe6 100644 --- a/frontend/sw360-portlet/src/main/webapp/html/projects/includes/projects/administrationEdit.jspf +++ b/frontend/sw360-portlet/src/main/webapp/html/projects/includes/projects/administrationEdit.jspf @@ -11,6 +11,8 @@ <%@ page import="org.eclipse.sw360.datahandler.thrift.projects.Project" %> +<%@ taglib prefix="core_rt" uri="http://java.sun.com/jstl/core_rt" %> +
@@ -111,6 +113,24 @@
+ + + + + + + + + + + + +
ObligationFulfilled
${entry.getKey().getText()}checked="checked" + />
+ diff --git a/libraries/lib-datahandler/src/main/java/org/eclipse/sw360/datahandler/common/SW360Utils.java b/libraries/lib-datahandler/src/main/java/org/eclipse/sw360/datahandler/common/SW360Utils.java index eae812b1a5..d95f5a27cd 100644 --- a/libraries/lib-datahandler/src/main/java/org/eclipse/sw360/datahandler/common/SW360Utils.java +++ b/libraries/lib-datahandler/src/main/java/org/eclipse/sw360/datahandler/common/SW360Utils.java @@ -24,14 +24,20 @@ import org.apache.log4j.Logger; import org.apache.thrift.TEnum; import org.apache.thrift.TException; -import org.eclipse.sw360.datahandler.thrift.*; +import org.eclipse.sw360.datahandler.thrift.ProjectReleaseRelationship; +import org.eclipse.sw360.datahandler.thrift.SW360Exception; +import org.eclipse.sw360.datahandler.thrift.ThriftClients; +import org.eclipse.sw360.datahandler.thrift.ThriftUtils; import org.eclipse.sw360.datahandler.thrift.components.*; import org.eclipse.sw360.datahandler.thrift.licenses.License; import org.eclipse.sw360.datahandler.thrift.licenses.LicenseService; +import org.eclipse.sw360.datahandler.thrift.licenses.Todo; import org.eclipse.sw360.datahandler.thrift.projects.Project; import org.eclipse.sw360.datahandler.thrift.projects.ProjectLink; import org.eclipse.sw360.datahandler.thrift.projects.ProjectService; +import org.eclipse.sw360.datahandler.thrift.projects.ProjectTodo; import org.eclipse.sw360.datahandler.thrift.users.User; +import org.eclipse.sw360.datahandler.thrift.users.UserService; import org.eclipse.sw360.datahandler.thrift.vendors.Vendor; import org.eclipse.sw360.datahandler.thrift.vulnerabilities.Vulnerability; import org.jetbrains.annotations.NotNull; @@ -69,6 +75,42 @@ private SW360Utils() { // Utility class with only static functions } + public static class TodoInfo { + public final boolean fulfilled; + public final String timestamp; + public final String user; + + public TodoInfo(ProjectTodo projectTodo) { + final UserService.Iface userClient = new ThriftClients().makeUserClient(); + + String userString = ""; + + User user; + try { + if (projectTodo.userId != null) { + user = userClient.getUser(projectTodo.userId); + if (user != null) { + userString = String.format("%s <%s>", user.getFullname(), user.getEmail()); + } + } + } catch (TException te) { + log.error("Could not load user from backend.", te); + } + + this.user = userString; + this.fulfilled = projectTodo.fulfilled; + this.timestamp = Strings.nullToEmpty(projectTodo.updated); + } + + public String getModificationHint() { + return String.format("%s %s",this.user, this.timestamp); + } + + public boolean isFulfilled() { + return fulfilled; + } + } + static{ objectMapper = new ObjectMapper(); SimpleModule customModule = new SimpleModule("SW360 serializers"); @@ -197,6 +239,26 @@ public static String printFullname(Release release) { return getReleaseFullname(vendorName, release.getName(), release.getVersion()); } + public static Map getProjectObligations(Project project) { + final LicenseService.Iface licenseClient = new ThriftClients().makeLicenseClient(); + + Set projectTodos = project.getTodosSize() > 0 ? project.getTodos() : Collections.emptySet(); + try { + return licenseClient.getTodos().stream() + .filter(o -> o.isValidForProject()) + .collect(Collectors.toMap( + todo -> todo, + todo -> new TodoInfo(projectTodos.stream() + .filter(projectTodo -> projectTodo.getTodoId().equals(todo.getId())) + .findFirst() + .orElseGet(ProjectTodo::new)) + ) + ); + } catch (TException te) { + return Collections.emptyMap(); + } + } + @NotNull public static String getReleaseFullname(String vendorName, String releaseName, String version) { StringBuilder sb = new StringBuilder(); diff --git a/libraries/lib-datahandler/src/main/thrift/licenses.thrift b/libraries/lib-datahandler/src/main/thrift/licenses.thrift index e7dd0864ef..323df2118a 100644 --- a/libraries/lib-datahandler/src/main/thrift/licenses.thrift +++ b/libraries/lib-datahandler/src/main/thrift/licenses.thrift @@ -50,6 +50,9 @@ struct Todo { // information from external data sources 19: optional map externalIds, + + // is valid for Projects + 20: optional bool validForProject, } struct RiskCategory { diff --git a/libraries/lib-datahandler/src/main/thrift/projects.thrift b/libraries/lib-datahandler/src/main/thrift/projects.thrift index 3742129cb2..c1f98b220b 100644 --- a/libraries/lib-datahandler/src/main/thrift/projects.thrift +++ b/libraries/lib-datahandler/src/main/thrift/projects.thrift @@ -14,6 +14,7 @@ include "attachments.thrift" include "vendors.thrift" include "components.thrift" include "sw360.thrift" +include "licenses.thrift" namespace java org.eclipse.sw360.datahandler.thrift.projects namespace php sw360.thrift.projects @@ -32,6 +33,7 @@ typedef attachments.Attachment Attachment typedef components.ReleaseLink ReleaseLink typedef components.ReleaseClearingStatusData ReleaseClearingStatusData typedef sw360.AddDocumentRequestSummary AddDocumentRequestSummary +typedef licenses.Todo Todo const string CLEARING_TEAM_UNKNOWN = "Unknown" @@ -120,6 +122,7 @@ struct Project { 138: optional string specialRisks3rdParty, 139: optional string deliveryChannels, 140: optional string remarksAdditionalRequirements, + 141: optional set todos, // Urls for the project 50: optional string homepage, @@ -156,6 +159,13 @@ struct ProjectWithReleaseRelationTuple { 2: required ProjectReleaseRelationship relation, } +struct ProjectTodo { + 1: required string todoId; + 2: required string userId; + 3: required string updated; + 4: required bool fulfilled; +} + service ProjectService { // Summary getters @@ -323,5 +333,4 @@ service ProjectService { * external ids can have multiple values to one key */ set searchByExternalIds(1: map> externalIds, 2: User user); - } diff --git a/rest/resource-server/src/main/java/org/eclipse/sw360/rest/resourceserver/core/JacksonCustomizations.java b/rest/resource-server/src/main/java/org/eclipse/sw360/rest/resourceserver/core/JacksonCustomizations.java index dc8e245778..87db28083f 100644 --- a/rest/resource-server/src/main/java/org/eclipse/sw360/rest/resourceserver/core/JacksonCustomizations.java +++ b/rest/resource-server/src/main/java/org/eclipse/sw360/rest/resourceserver/core/JacksonCustomizations.java @@ -144,6 +144,8 @@ static abstract class MultiStatusMixin extends MultiStatus { "setReleaseIds", "setPermissions", "setClearingState", + "setTodos", + "todosSize", "securityResponsibles", "securityResponsiblesSize", "securityResponsiblesIterator",