Skip to content
This repository has been archived by the owner on Jul 25, 2018. It is now read-only.

Commit

Permalink
Merge pull request #521 from ChristophNiehoff/feat/455-provide-more-i…
Browse files Browse the repository at this point in the history
…nformation-when-linking-releases

feat(ui): More information for releases search

tested-by: [email protected]
reviewed-by: [email protected], [email protected]
  • Loading branch information
alexbrdn authored Aug 23, 2017
2 parents 8314aa1 + 69e9dba commit 303f168
Show file tree
Hide file tree
Showing 22 changed files with 349 additions and 319 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ private void setShortSummaryFields(Release document, Release copy) {
copyField(document, copy, _Fields.COMPONENT_ID);
copyField(document, copy, _Fields.CLEARING_TEAM_TO_FOSSOLOGY_STATUS);
copyField(document, copy, _Fields.FOSSOLOGY_ID);
copyField(document, copy, _Fields.CLEARING_STATE);
copyField(document, copy, _Fields.MAINLINE_STATE);
}

private void setAdditionalFieldsForSummariesOtherThanShortAndDetailedExport(Release document, Release copy){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public Set<Project> getAccessibleProjects(User user) {
}

public List<Project> searchByName(String name, User user) {
return searchByName(name, user, SummaryType.SHORT);
return searchByName(name, user, SummaryType.SUMMARY);
}

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,14 @@ public class PortalConstants {
public static final String WHERE_ARRAY = "where[]";
public static final String HOW = "how";

//! Specialized keys for CSS-classes of project (clearing) state boxes
public static final String PROJECT_STATE_ACTIVE__CSS = "projectStateActive";
public static final String PROJECT_STATE_INACTIVE__CSS = "projectStateInactive";
public static final String CLEARING_STATE_OPEN__CSS = "clearingStateOpen";
public static final String CLEARING_STATE_INPROGRESS__CSS = "clearingStateInProgress";
public static final String CLEARING_STATE_CLOSED__CSS = "clearingStateClosed";
public static final String CLEARING_STATE_UNKNOWN__CSS = "clearingStateUnknown";

//! Serve resource keywords

//! Actions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,17 +250,12 @@ private void serveUnsubscribeRelease(ResourceRequest request, ResourceResponse r
private void serveLinkedReleases(ResourceRequest request, ResourceResponse response) throws IOException, PortletException {
String what = request.getParameter(PortalConstants.WHAT);

String projectId = request.getParameter(RELEASE_ID);

if (PortalConstants.LIST_NEW_LINKED_RELEASES.equals(what)) {
String[] where = request.getParameterValues(PortalConstants.WHERE_ARRAY);
serveNewTableRowLinkedRelease(request, response, where);
} else if (PortalConstants.RELEASE_SEARCH.equals(what)) {
String where = request.getParameter(PortalConstants.WHERE);
serveReleaseSearchResults(request, response, where);
} else if (PortalConstants.RELEASE_SEARCH_BY_VENDOR.equals(what)) {
String where = request.getParameter(PortalConstants.WHERE);
serveReleaseSearchResultsByVendor(request, response, where);
}
}

Expand Down Expand Up @@ -289,31 +284,26 @@ private void serveNewTableRowLinkedRelease(ResourceRequest request, ResourceResp
}

private void serveReleaseSearchResults(ResourceRequest request, ResourceResponse response, String searchText) throws IOException, PortletException {
serveReleaseSearch(request, response, searchText, false);
serveReleaseSearch(request, response, searchText);
}

private void serveReleaseSearchResultsByVendor(ResourceRequest request, ResourceResponse response, String searchText) throws IOException, PortletException {
serveReleaseSearch(request, response, searchText, true);
}

private void serveReleaseSearch(ResourceRequest request, ResourceResponse response, String searchText, boolean searchByVendor) throws IOException, PortletException {
private void serveReleaseSearch(ResourceRequest request, ResourceResponse response, String searchText) throws IOException, PortletException {
List<Release> searchResult;

try {
ComponentService.Iface componentClient = thriftClients.makeComponentClient();
if (searchByVendor) {

searchResult = componentClient.searchReleaseByNamePrefix(searchText);

if(searchText != "") {
final VendorService.Iface vendorClient = thriftClients.makeVendorClient();
final Set<String> vendorIds = vendorClient.searchVendorIds(searchText);
if (vendorIds != null && vendorIds.size() > 0) {
searchResult = componentClient.getReleasesFromVendorIds(vendorIds);
} else {
searchResult = Collections.emptyList();
searchResult.addAll(componentClient.getReleasesFromVendorIds(vendorIds));
}
} else {
searchResult = componentClient.searchReleaseByNamePrefix(searchText);
}
} catch (TException e) {
log.error("Error searching projects", e);
log.error("Error searching linked releases", e);
searchResult = Collections.emptyList();
}

Expand All @@ -322,6 +312,7 @@ private void serveReleaseSearch(ResourceRequest request, ResourceResponse respon
include("/html/utils/ajax/searchReleasesAjax.jsp", request, response, PortletRequest.RESOURCE_PHASE);
}


//! VIEW and helpers
@Override
public void doView(RenderRequest request, RenderResponse response) throws IOException, PortletException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,6 @@ private void serveLinkedReleases(ResourceRequest request, ResourceResponse respo
} else if (PortalConstants.RELEASE_SEARCH.equals(what)) {
String where = request.getParameter(PortalConstants.WHERE);
serveReleaseSearchResults(request, response, where);
} else if (PortalConstants.RELEASE_SEARCH_BY_VENDOR.equals(what)) {
String where = request.getParameter(PortalConstants.WHERE);
serveReleaseSearchResultsByVendor(request, response, where);
} else if (PortalConstants.RELEASE_LIST_FROM_LINKED_PROJECTS.equals(what)) {
serveReleasesFromLinkedProjects(request, response, projectId);
}
Expand Down Expand Up @@ -432,30 +429,30 @@ private void serveProjectSearchResults(ResourceRequest request, ResourceResponse
}

private void serveReleaseSearchResults(ResourceRequest request, ResourceResponse response, String searchText) throws IOException, PortletException {
serveReleaseSearch(request, response, searchText, false);
}

private void serveReleaseSearchResultsByVendor(ResourceRequest request, ResourceResponse response, String searchText) throws IOException, PortletException {
serveReleaseSearch(request, response, searchText, true);
serveReleaseSearch(request, response, searchText);
}


@SuppressWarnings("Duplicates")
private void serveReleaseSearch(ResourceRequest request, ResourceResponse response, String searchText, boolean searchByVendor) throws IOException, PortletException {
private void serveReleaseSearch(ResourceRequest request, ResourceResponse response, String searchText) throws IOException, PortletException {
List<Release> searchResult;

try {

ComponentService.Iface componentClient = thriftClients.makeComponentClient();
if (searchByVendor) {

// First: Search by name:
searchResult = componentClient.searchReleaseByNamePrefix(searchText);

// If one is searching for everything, then it makes no sense to search also by vendors, as 'searchResult' already contains all releases.
if(searchText != "") {
// Second: Search by vendor and append:
// Note: The search-by-vendor by definition does not give results if the search string is empty.
// Therefore, an empty-string search does not introduce duplicated results, which is nice.
final VendorService.Iface vendorClient = thriftClients.makeVendorClient();
final Set<String> vendorIds = vendorClient.searchVendorIds(searchText);
if (vendorIds != null && vendorIds.size() > 0) {
searchResult = componentClient.getReleasesFromVendorIds(vendorIds);
} else {
searchResult = Collections.emptyList();
searchResult.addAll(componentClient.getReleasesFromVendorIds(vendorIds));
}
} else {
searchResult = componentClient.searchReleaseByNamePrefix(searchText);
}
} catch (TException e) {
log.error("Error searching projects", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.apache.thrift.TEnum;
import org.eclipse.sw360.datahandler.common.ThriftEnumUtils;
import org.eclipse.sw360.datahandler.thrift.projects.ProjectState;
import org.eclipse.sw360.portal.common.PortalConstants;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.SimpleTagSupport;
Expand All @@ -26,9 +27,9 @@ public void setValue(ProjectState state) {
}

public String makeBox(ProjectState state) {
String projectStateBackgroundColour = "projectStateInactive";
String projectStateBackgroundColour = PortalConstants.PROJECT_STATE_INACTIVE__CSS;
if( state == ProjectState.ACTIVE ) {
projectStateBackgroundColour = "projectStateActive";
projectStateBackgroundColour = PortalConstants.PROJECT_STATE_ACTIVE__CSS;
}
return "<div class=\"stateBox capsuleLeft capsuleRight " + projectStateBackgroundColour + "\" title=\"Project state: " + state + "\"> PS </div>";
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Copyright Siemens AG, 2017.
* Part of the SW360 Portal Project.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.sw360.portal.tags;

import org.eclipse.sw360.datahandler.common.ThriftEnumUtils;
import org.eclipse.sw360.datahandler.thrift.projects.Project;
import org.eclipse.sw360.datahandler.thrift.projects.ProjectState;
import org.eclipse.sw360.portal.common.PortalConstants;


import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.JspTag;
import javax.servlet.jsp.tagext.SimpleTagSupport;
import java.io.IOException;

import static org.eclipse.sw360.datahandler.thrift.projects.ProjectClearingState.*;

public class DisplayStateBoxes extends SimpleTagSupport {

private Project project;

public void setProject(Project project) {
this.project = project;
}

public String makeBoxes() {
// The hardcoded strings correspond to CSS classes defined in sw360.css

// Add project state color to boxes if the project is active
// (default color is grey)
String projectStateBackgroundColour = PortalConstants.PROJECT_STATE_INACTIVE__CSS;
if( project.isSetState() && project.state == ProjectState.ACTIVE ) { // -> green
projectStateBackgroundColour = PortalConstants.PROJECT_STATE_ACTIVE__CSS;
}

// Add clearingstate color to boxes in projects list
// (default color is grey)
String clearingStateBackgroundColour = PortalConstants.CLEARING_STATE_UNKNOWN__CSS;

if(project.isSetClearingState()) {
switch(project.clearingState) {
case CLOSED: // -> green
clearingStateBackgroundColour = PortalConstants.CLEARING_STATE_CLOSED__CSS;
break;
case IN_PROGRESS: // -> yellow
clearingStateBackgroundColour = PortalConstants.CLEARING_STATE_INPROGRESS__CSS;
break;
case OPEN: // -> red
clearingStateBackgroundColour = PortalConstants.CLEARING_STATE_OPEN__CSS;
break;
}
}

String box_PS = "<div class=\"stateBox " + projectStateBackgroundColour + " capsuleLeft \" title=\"Project state: " + ThriftEnumUtils.enumToString(project.state) + "\"> PS </div>";
String box_CS = "<div class=\"stateBox capsuleRight " + clearingStateBackgroundColour + "\" title=\"Project clearing state: " + ThriftEnumUtils.enumToString(project.clearingState) + "\"> CS </div>";

return box_PS+box_CS;
}


public void doTag() throws JspException, IOException {
getJspContext().getOut().print( makeBoxes() );
}
}
11 changes: 11 additions & 0 deletions frontend/sw360-portlet/src/main/webapp/WEB-INF/customTags.tld
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,17 @@
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<tag>
<name>DisplayStateBoxes</name>
<tag-class>org.eclipse.sw360.portal.tags.DisplayStateBoxes</tag-class>
<body-content>empty</body-content>
<attribute>
<name>project</name>
<required>true</required>
<type>org.eclipse.sw360.datahandler.thrift.projects.Project</type>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<tag>
<name>DisplayProjectStateBox</name>
<tag-class>org.eclipse.sw360.portal.tags.DisplayProjectStateBox</tag-class>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
</div>
<core_rt:if test="${not addMode}">
<div id="tab-ReleaseClearingInformation">
<%@include file="/html/components/includes/releases/editReleaseClearingInformation.jspf" %>
<%@include file="/html/components/includes/releases/editReleaseClearingInformation.jspf" %>
</div>
<div id="tab-ReleaseECCInformation">
<%@include file="/html/components/includes/releases/editReleaseECCInformation.jspf" %>
Expand Down Expand Up @@ -149,13 +149,13 @@
<jsp:include page="/html/utils/includes/searchAndSelect.jsp" />
<jsp:include page="/html/utils/includes/searchUsers.jsp" />
<jsp:include page="/html/utils/includes/searchLicenses.jsp" />
<jsp:include page="/html/utils/includes/searchReleasesFromRelease.jsp" />
<%@ include file="/html/utils/includes/requirejs.jspf" %>
<core_rt:set var="enableSearchForReleasesFromLinkedProjects" value="${false}" scope="request"/>
<jsp:include page="/html/utils/includes/searchReleases.jsp" />
</core_rt:if>

<%@include file="/html/components/includes/vendors/searchVendor.jspf" %>

<%--for javascript library loading --%>
<%@ include file="/html/utils/includes/requirejs.jspf" %>
<script>
var tabView;
var Y = YUI().use(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@
<tr>
<td><input type="checkbox" name="<portlet:namespace/>projectId" value="${entry.id}"></td>
<td><sw360:ProjectName project="${entry}"/></td>
<td><sw360:out value="${entry.version}"/></td>
<td><sw360:DisplayStateBoxes project="${entry}"/></td>
<td><sw360:DisplayUserEmail email="${entry.projectResponsible}" bare="true"/></td>
<td><sw360:out value="${entry.description}"/></td>
</tr>
</core_rt:forEach>
</core_rt:if>
<core_rt:if test="${projectSearch.size() == 0}">
<tr><td colspan="3">
<tr><td colspan="6">
No project found with your search.
</td></tr>

Expand Down
2 changes: 2 additions & 0 deletions frontend/sw360-portlet/src/main/webapp/html/projects/edit.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
<form id="projectEditForm" name="projectEditForm" action="<%=updateURL%>" method="post" >
<%@include file="/html/projects/includes/projects/basicInfo.jspf" %>
<%@include file="/html/projects/includes/linkedProjectsEdit.jspf" %>
<%@ include file="/html/utils/includes/requirejs.jspf" %>
<%@include file="/html/utils/includes/linkedReleasesEdit.jspf" %>
<core_rt:if test="${not addMode}" >
<%@include file="/html/utils/includes/editAttachments.jsp" %>
Expand All @@ -96,6 +97,7 @@
</core_rt:if>
</form>
<jsp:include page="/html/projects/includes/searchProjects.jsp" />
<core_rt:set var="enableSearchForReleasesFromLinkedProjects" value="${true}" scope="request"/>
<jsp:include page="/html/utils/includes/searchReleases.jsp" />
<jsp:include page="/html/utils/includes/searchAndSelect.jsp" />
<jsp:include page="/html/utils/includes/searchUsers.jsp" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
~ which accompanies this distribution, and is available at
~ http://www.eclipse.org/legal/epl-v10.html
--%>
<link rel="stylesheet" href="<%=request.getContextPath()%>/webjars/github-com-craftpip-jquery-confirm/3.0.1/jquery-confirm.min.css">
<script src="<%=request.getContextPath()%>/webjars/github-com-craftpip-jquery-confirm/3.0.1/jquery-confirm.min.js" type="text/javascript"></script>
<script>
function deleteProjectLink(rowId) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
</tbody>
</table>

<input type="button" class="addButton" onclick="showProjectDialog();" value="Click to add linked Projects" >
<input type="button" class="addButton" id="addLinkedProjectButton" value="Click to add linked Projects" >
<br/>
<br/>
Loading

0 comments on commit 303f168

Please sign in to comment.