use of org.eclipse.sw360.datahandler.thrift.components.Release._Fields in project sw360portal by sw360.
the class FossologyAwarePortlet method serveFossologyStatus.
protected void serveFossologyStatus(ResourceRequest request, ResourceResponse response) throws IOException {
DataTablesParameters parameters = DataTablesParser.parametersFrom(request);
Release release = getReleaseForFossologyStatus(request);
Map<String, FossologyStatus> fossologyStatus = getFossologyStatus(release);
JSONObject jsonResponse = JSONFactoryUtil.createJSONObject();
JSONArray data = JSONFactoryUtil.createJSONArray();
for (Map.Entry<String, FossologyStatus> entry : fossologyStatus.entrySet()) {
JSONObject row = JSONFactoryUtil.createJSONObject();
row.put("0", entry.getKey());
row.put("1", ThriftEnumUtils.enumToString(entry.getValue()));
data.put(row);
}
jsonResponse.put("attachment", getFossologyUploadableAttachment(release));
jsonResponse.put("data", data);
jsonResponse.put("draw", parameters.getDraw());
jsonResponse.put("recordsTotal", fossologyStatus.size());
jsonResponse.put("recordsFiltered", fossologyStatus.size());
writeJSON(request, response, jsonResponse);
}
use of org.eclipse.sw360.datahandler.thrift.components.Release._Fields in project sw360portal by sw360.
the class FossologyAwarePortlet method getReleaseForFossologyStatus.
protected Release getReleaseForFossologyStatus(ResourceRequest request) {
String releaseId = request.getParameter(RELEASE_ID);
String clearingTeam = request.getParameter(CLEARING_TEAM);
boolean cached = Boolean.parseBoolean(request.getParameter("cached"));
if (!isNullOrEmpty(releaseId) && !isNullOrEmpty(clearingTeam)) {
try {
final Release release;
if (!cached) {
FossologyService.Iface client = thriftClients.makeFossologyClient();
release = client.getStatusInFossology(releaseId, UserCacheHolder.getUserFromRequest(request), clearingTeam);
} else {
ComponentService.Iface client = thriftClients.makeComponentClient();
release = client.getReleaseById(releaseId, UserCacheHolder.getUserFromRequest(request));
}
if (release != null) {
return release;
} else {
log.error("no response from backend!");
}
} catch (TException e) {
log.error("Could not release status in fossology", e);
}
}
log.error("Could not get release from request");
return null;
}
use of org.eclipse.sw360.datahandler.thrift.components.Release._Fields in project sw360portal by sw360.
the class ComponentUploadPortlet method dealWithReleaseLinksContainedInRelease.
private void dealWithReleaseLinksContainedInRelease(Map<String, Component> componentsById, Map<String, Release> releasesById, Component component, Release release, List<Iterable<String>> csvRows) throws IOException {
final Map<String, ReleaseRelationship> releaseIdToRelationship = release.getReleaseIdToRelationship();
if (releaseIdToRelationship != null) {
for (Map.Entry<String, ReleaseRelationship> idReleaseRelationshipEntry : releaseIdToRelationship.entrySet()) {
final Release linkedRelease = releasesById.get(idReleaseRelationshipEntry.getKey());
if (linkedRelease != null) {
final ReleaseRelationship relationship = idReleaseRelationshipEntry.getValue();
final Component linkedComponent = componentsById.get(linkedRelease.getComponentId());
if (linkedComponent != null) {
printReleaseLinkEntry(component, release, linkedRelease, relationship, linkedComponent, csvRows);
}
}
}
}
}
use of org.eclipse.sw360.datahandler.thrift.components.Release._Fields in project sw360portal by sw360.
the class COTSDetailsModerationRequestGenerator method setAdditionsAndDeletions.
@Override
public ModerationRequest setAdditionsAndDeletions(ModerationRequest request, COTSDetails update, COTSDetails actual) {
updateDocument = update == null ? new COTSDetails() : update;
actualDocument = actual == null ? new COTSDetails() : actual;
documentAdditions = null;
documentDeletions = null;
for (COTSDetails._Fields field : COTSDetails._Fields.values()) {
if (COTSDetails.metaDataMap.get(field).valueMetaData.type == TType.BOOL || COTSDetails.metaDataMap.get(field).valueMetaData.type == TType.I32) {
if (actualDocument.getFieldValue(field) != updateDocument.getFieldValue(field)) {
if (documentAdditions == null) {
documentAdditions = new COTSDetails();
}
if (documentDeletions == null) {
documentDeletions = new COTSDetails();
}
documentAdditions.setFieldValue(field, updateDocument.getFieldValue(field));
documentDeletions.setFieldValue(field, actualDocument.getFieldValue(field));
}
continue;
}
if (COTSDetails.metaDataMap.get(field).valueMetaData.type == TType.STRING) {
if (isNullOrEmpty((String) actualDocument.getFieldValue(field)) && isNullOrEmpty((String) updateDocument.getFieldValue(field))) {
continue;
}
if (actualDocument.isSet(field) && !updateDocument.isSet(field)) {
if (documentDeletions == null) {
documentDeletions = new COTSDetails();
}
documentDeletions.setFieldValue(field, actualDocument.getFieldValue(field));
continue;
}
if (updateDocument.isSet(field) && !actualDocument.isSet(field)) {
if (documentAdditions == null) {
documentAdditions = new COTSDetails();
}
documentAdditions.setFieldValue(field, updateDocument.getFieldValue(field));
continue;
}
if (!(actualDocument.getFieldValue(field).equals(updateDocument.getFieldValue(field)))) {
if (documentAdditions == null) {
documentAdditions = new COTSDetails();
}
if (documentDeletions == null) {
documentDeletions = new COTSDetails();
}
documentAdditions.setFieldValue(field, updateDocument.getFieldValue(field));
documentDeletions.setFieldValue(field, actualDocument.getFieldValue(field));
}
}
}
request.getReleaseAdditions().setCotsDetails(documentAdditions);
request.getReleaseDeletions().setCotsDetails(documentDeletions);
return request;
}
use of org.eclipse.sw360.datahandler.thrift.components.Release._Fields in project sw360portal by sw360.
the class ComponentModerationRequestGenerator method setAdditionsAndDeletions.
@Override
public ModerationRequest setAdditionsAndDeletions(ModerationRequest request, Component updateComponent, Component actualComponent) {
updateDocument = updateComponent;
actualDocument = actualComponent;
documentAdditions = new Component();
documentDeletions = new Component();
// required fields:
documentAdditions.setName(updateComponent.getName());
documentAdditions.setId(actualComponent.getId());
documentDeletions.setName(actualComponent.getName());
documentDeletions.setId(actualComponent.getId());
for (Component._Fields field : Component._Fields.values()) {
if (actualComponent.getFieldValue(field) == null) {
documentAdditions.setFieldValue(field, updateComponent.getFieldValue(field));
} else if (updateComponent.getFieldValue(field) == null) {
documentDeletions.setFieldValue(field, actualComponent.getFieldValue(field));
} else if (!actualComponent.getFieldValue(field).equals(updateComponent.getFieldValue(field))) {
switch(field) {
// ignored fields
case PERMISSIONS:
case DOCUMENT_STATE:
// releases and related fields are not updated via moderation requests
case RELEASES:
case RELEASE_IDS:
case MAIN_LICENSE_IDS:
case LANGUAGES:
case OPERATING_SYSTEMS:
case VENDOR_NAMES:
break;
case ATTACHMENTS:
dealWithAttachments(Component._Fields.ATTACHMENTS);
break;
case ROLES:
dealWithCustomMap(Component._Fields.ROLES);
break;
default:
dealWithBaseTypes(field, Component.metaDataMap.get(field));
}
}
}
request.setComponentAdditions(documentAdditions);
request.setComponentDeletions(documentDeletions);
return request;
}
Aggregations