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

Commit

Permalink
feat(ui): extend external ids for projects and components
Browse files Browse the repository at this point in the history
- add external ids to components (view/edit/merge)
- add external id in the edit page of the project
  • Loading branch information
maierthomas committed Dec 21, 2017
1 parent 7792e24 commit 05a6838
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 30 deletions.
Expand Up @@ -20,7 +20,6 @@
import org.eclipse.sw360.datahandler.thrift.vendors.Vendor;
import org.eclipse.sw360.datahandler.thrift.vendors.VendorService;
import org.eclipse.sw360.datahandler.thrift.vulnerabilities.ReleaseVulnerabilityRelation;
import org.eclipse.sw360.portal.common.CustomFieldHelper;
import org.eclipse.sw360.portal.common.PortalConstants;
import org.eclipse.sw360.portal.common.PortletUtils;
import org.eclipse.sw360.portal.users.UserCacheHolder;
Expand All @@ -31,13 +30,13 @@

import static com.google.common.base.Strings.isNullOrEmpty;
import static org.eclipse.sw360.datahandler.common.SW360Utils.newDefaultEccInformation;
import static org.eclipse.sw360.portal.common.PortalConstants.CUSTOM_FIELD_COMPONENTS_VIEW_SIZE;

/**
* Component portlet implementation
*
* @author cedric.bodet@tngtech.com
* @author Johannes.Najjar@tngtech.com
* @author thomas.maier@evosoft.com
*/
public abstract class ComponentPortletUtils {

Expand Down Expand Up @@ -132,7 +131,8 @@ static void updateComponentFromRequest(PortletRequest request, Component compone
break;
case ROLES:
component.setRoles(PortletUtils.getCustomMapFromRequest(request));

case EXTERNAL_IDS:
component.setExternalIds(PortletUtils.getExternalIdMapFromRequest(request));

default:
setFieldValue(request, component, field);
Expand Down
Expand Up @@ -51,6 +51,7 @@
* @author cedric.bodet@tngtech.com
* @author Johannes.Najjar@tngtech.com
* @author alex.borodin@evosoft.com
* @author thomas.maier@evosoft.com
*/
public class ProjectPortletUtils {

Expand Down Expand Up @@ -90,6 +91,8 @@ public static void updateProjectFromRequest(PortletRequest request, Project proj

case ROLES:
project.setRoles(PortletUtils.getCustomMapFromRequest(request));
case EXTERNAL_IDS:
project.setExternalIds(PortletUtils.getExternalIdMapFromRequest(request));
default:
setFieldValue(request, project, field);
}
Expand Down
Expand Up @@ -115,6 +115,8 @@
<div id="editField" class="content2">
<form id="componentEditForm" name="componentEditForm" action="<%=updateComponentURL%>" method="post">
<%@include file="/html/components/includes/components/editBasicInfo.jspf" %>
<core_rt:set var="externalIdsSet" value="${component.externalIds.entrySet()}"/>
<%@include file="/html/utils/includes/editExternalIds.jsp" %>
<core_rt:if test="${not componentDivAddMode}">
<%@include file="/html/utils/includes/editAttachments.jspf" %>
<core_rt:set var="documentName"><sw360:out value='${component.name}'/></core_rt:set>
Expand Down Expand Up @@ -228,8 +230,3 @@ require(['jquery', 'modules/sw360Validate', 'modules/autocomplete', 'modules/con
});
</script>





Expand Up @@ -114,7 +114,7 @@
<%@include file="/html/utils/includes/mapEdit.jspf" %>

<core_rt:set var="externalIdsSet" value="${release.externalIds.entrySet()}"/>
<%@include file="/html/components/includes/releases/editExternalIds.jsp" %>
<%@include file="/html/utils/includes/editExternalIds.jsp" %>
<%@include file="/html/components/includes/releases/editReleaseRepository.jspf" %>
</div>
<div id="tab-ReleaseLinks">
Expand Down Expand Up @@ -195,20 +195,6 @@
$('#formSubmit').click(
function() {
var valid = true;
$.each($('#externalIdsTable tr.bodyRow'), function (i, row) {
var key = $('#'+row.id+' td input.keyClass').val();
var value = $('#'+row.id+' td input.valueClass').val();
var isOneEmpty = ((key !== '') && (value === '')) || ((key === '') && (value !== ''));
if (isOneEmpty) {
$.alert('There is a blank field in one or more of your external ids. Please correct this before updating the release.');
valid = false;
return false;
}
});
if (!valid) {
return;
}
<core_rt:choose>
<core_rt:when test="${addMode || release.permissions[WRITE]}">
$('#releaseEditForm').submit();
Expand Down Expand Up @@ -302,4 +288,3 @@
}
});
</script>

Expand Up @@ -53,6 +53,10 @@
<td>Mailing list:</td>
<td><sw360:DisplayLink target="mailto:${component.mailinglist}" text="${component.mailinglist}"/></td>
</tr>
<tr>
<td>External ids:</td>
<td><sw360:DisplayMap value="${component.externalIds}"/></td>
</tr>
</table>
<table class="table info_table" id="releaseAggregateTable">
<thead>
Expand Down
Expand Up @@ -159,6 +159,8 @@
$stepElement.append(wizard.createSingleMergeLine('Wiki', data.componentTarget.wiki, data.componentSource.wiki));
$stepElement.append(wizard.createSingleMergeLine('Mailing list', data.componentTarget.mailinglist, data.componentSource.mailinglist));
$stepElement.append(wizard.createSingleMergeLine('Description', data.componentTarget.description, data.componentSource.description));
$stepElement.append(wizard.createSingleMergeLine('External ids', data.componentTarget.externalids, data.componentSource.externalids));
$stepElement.append(wizard.createCategoryLine('Roles'));
$stepElement.append(wizard.createSingleMergeLine('Component owner', data.componentTarget.componentOwner, data.componentSource.componentOwner));
Expand Down Expand Up @@ -204,6 +206,7 @@
componentSelection.wiki = wizard.getFinalSingleValue('Wiki');
componentSelection.mailinglist = wizard.getFinalSingleValue('Mailing list');
componentSelection.description = wizard.getFinalSingleValue('Description');
componentSelection.externalids = wizard.getFinalSingleValue('External ids');
componentSelection.componentOwner = wizard.getFinalSingleValue('Component owner');
componentSelection.ownerAccountingUnit = wizard.getFinalSingleValue('Owner accounting unit');
Expand Down
5 changes: 2 additions & 3 deletions frontend/sw360-portlet/src/main/webapp/html/projects/edit.jsp
Expand Up @@ -95,6 +95,8 @@
<core_rt:set var="documentName"><sw360:ProjectName project="${project}"/></core_rt:set>
<%@include file="/html/utils/includes/usingProjectsTable.jspf" %>
<%@include file="/html/utils/includes/usingComponentsTable.jspf"%>
<core_rt:set var="externalIdsSet" value="${project.externalIds.entrySet()}"/>
<%@include file="/html/utils/includes/editExternalIds.jsp" %>
</div>
<div id="tab-Administration" >
<%@include file="/html/projects/includes/projects/administrationEdit.jspf" %>
Expand Down Expand Up @@ -176,7 +178,6 @@ require(['jquery', 'modules/sw360Validate', 'modules/confirm' ], function($, sw3
showCommentField();
</core_rt:otherwise>
</core_rt:choose>
}
);
});
Expand Down Expand Up @@ -250,5 +251,3 @@ require(['jquery', 'modules/sw360Validate', 'modules/confirm' ], function($, sw3
}
});
</script>


Expand Up @@ -9,7 +9,6 @@
~ http://www.eclipse.org/legal/epl-v10.html
--%>
<%@ page import="org.eclipse.sw360.portal.common.PortalConstants" %>
<%@ page import="org.eclipse.sw360.datahandler.thrift.components.Release" %>

<table class="table info_table" id="externalIdsTable">
<thead>
Expand Down Expand Up @@ -52,10 +51,10 @@
var newRowAsString =
'<tr id="' + rowId + '" class="bodyRow">' +
'<td width="46%">' +
'<input class="keyClass" id="<%=PortalConstants.EXTERNAL_ID_KEY%>' + rowId + '" name="<portlet:namespace/><%=PortalConstants.EXTERNAL_ID_KEY%>' + rowId + '" class="toplabelledInput" placeholder="Input name" title="Input name" value="' + key + '"/>' +
'<input class="keyClass" id="<%=PortalConstants.EXTERNAL_ID_KEY%>' + rowId + '" name="<portlet:namespace/><%=PortalConstants.EXTERNAL_ID_KEY%>' + rowId + '" required="" minlength="1" class="toplabelledInput" placeholder="Enter external id key" title="Input name" value="' + key + '"/>' +
'</td>' +
'<td width="46%">' +
'<input class="valueClass" id="<%=PortalConstants.EXTERNAL_ID_VALUE%>' + rowId + '" name="<portlet:namespace/><%=PortalConstants.EXTERNAL_ID_VALUE%>' + rowId + '" class="toplabelledInput" placeholder="Input id" title="Input id" value="' + value + '"/>' +
'<input class="valueClass" id="<%=PortalConstants.EXTERNAL_ID_VALUE%>' + rowId + '" name="<portlet:namespace/><%=PortalConstants.EXTERNAL_ID_VALUE%>' + rowId + '" required="" minlength="1" class="toplabelledInput" placeholder="Enter external id value" title="Input id" value="' + value + '"/>' +
'</td>' +
'<td class="deletor" width="8%">' +
'<img src="<%=request.getContextPath()%>/images/Trash.png" onclick="deleteMapItem(\'' + rowId + '\')" alt="Delete">' +
Expand Down
3 changes: 3 additions & 0 deletions libraries/lib-datahandler/src/main/thrift/components.thrift
Expand Up @@ -253,6 +253,9 @@ struct Component {
28: optional string ownerGroup,
29: optional map<string,set<string>> roles, //customized roles with set of mail addresses

// information from external data sources
30: optional map<string, string> externalIds,

// Linked objects
32: optional list<Release> releases,
33: optional set<string> releaseIds,
Expand Down
Expand Up @@ -234,6 +234,8 @@ static abstract class UserMixin extends User {
"languagesIterator",
"softwarePlatformsSize",
"softwarePlatformsIterator",
"setExternalIds",
"externalIdsSize",
"setSoftwarePlatforms",
"operatingSystemsSize",
"operatingSystemsIterator",
Expand Down

0 comments on commit 05a6838

Please sign in to comment.