use of org.eclipse.sw360.datahandler.thrift.components.FossologyStatus in project sw360portal by sw360.
the class FossologyFileHandlerTest method testIsVisible.
@Test
public void testIsVisible() throws Exception {
assertThat(FossologyFileHandler.isVisible(null), is(false));
for (FossologyStatus fossologyStatus : FossologyStatus.values()) {
final boolean expectedVisible;
switch(fossologyStatus) {
case CONNECTION_FAILED:
case ERROR:
case NON_EXISTENT:
case NOT_SENT:
case INACCESSIBLE:
expectedVisible = false;
break;
case SENT:
case SCANNING:
case OPEN:
case IN_PROGRESS:
case CLOSED:
case REJECTED:
case REPORT_AVAILABLE:
default:
expectedVisible = true;
break;
}
String errorMessage = "" + fossologyStatus + " should" + (expectedVisible ? "" : " not") + " be visible";
assertThat(errorMessage, FossologyFileHandler.isVisible(fossologyStatus), is(expectedVisible));
}
}
use of org.eclipse.sw360.datahandler.thrift.components.FossologyStatus in project sw360portal by sw360.
the class FossologyFileHandler method getStatusInFossology.
public Release getStatusInFossology(String releaseId, User user, String clearingTeam) throws TException {
final Release release;
final ComponentService.Iface componentClient;
try {
componentClient = thriftClients.makeComponentClient();
release = componentClient.getReleaseById(releaseId, user);
assertNotNull(release);
} catch (TException e) {
log.error("cannot get release " + releaseId, e);
throw e;
}
if (release.isSetFossologyId()) {
int fossologyId = CommonUtils.toUnsignedInt(release.getFossologyId());
boolean updateInDb = true;
for (String allClearingTeam : getAllClearingTeams(release, clearingTeam)) {
final FossologyStatus status = fossologyUploader.getStatusInFossology(fossologyId, allClearingTeam);
setFossologyStatus(release, allClearingTeam, status);
if (isError(status)) {
updateInDb = false;
}
}
Optional<FossologyStatus> maxStatus = nullToEmptyMap(release.getClearingTeamToFossologyStatus()).values().stream().max(FossologyStatus::compareTo);
updateReleaseClearingState(release, maxStatus);
if (updateInDb) {
updateRelease(release, user, componentClient);
}
}
// just unlockit
getReleaseAndUnlockIt(releaseId, user, componentClient);
return release;
}
use of org.eclipse.sw360.datahandler.thrift.components.FossologyStatus in project sw360portal by sw360.
the class FossologyFileHandler method sendToFossologyExistingUpload.
private RequestStatus sendToFossologyExistingUpload(Release release, User user, String clearingTeam, ComponentService.Iface componentClient) throws TException {
int fossologyUploadId;
fossologyUploadId = toUnsignedInt(release.getFossologyId());
failIf(fossologyUploadId <= 0, "release %s has an inconsistent FossologyId", release.getId());
FossologyStatus currentStatus = fossologyUploader.getStatusInFossology(fossologyUploadId, clearingTeam);
if (isVisible(currentStatus)) {
updateFossologyStatus(release, user, clearingTeam, currentStatus, componentClient);
return RequestStatus.SUCCESS;
} else {
return duplicateUploadFor(release, user, clearingTeam, fossologyUploadId, componentClient);
}
}
use of org.eclipse.sw360.datahandler.thrift.components.FossologyStatus in project sw360portal by sw360.
the class FossologyFileHandler method getReleaseAndUnlockIt.
protected Release getReleaseAndUnlockIt(String releaseId, User user, ComponentService.Iface componentClient) throws TException {
final Release release = componentClient.getReleaseById(releaseId, user);
assertNotNull(release, "cannot get release %s", releaseId);
final Collection<FossologyStatus> fossologyStatuses = nullToEmptyMap(release.getClearingTeamToFossologyStatus()).values();
if (!fossologyStatuses.isEmpty() && all(fossologyStatuses, equalTo(FossologyStatus.REJECTED))) {
release.unsetAttachmentInFossology();
release.unsetFossologyId();
release.unsetClearingTeamToFossologyStatus();
updateRelease(release, user, componentClient);
}
return release;
}
use of org.eclipse.sw360.datahandler.thrift.components.FossologyStatus in project sw360portal by sw360.
the class WhenComputeClearingState method team_$_sets_fossology_status_to.
public WhenComputeClearingState team_$_sets_fossology_status_to(@Quoted String clearingTeam, @TEnumToString FossologyStatus fossologyStatus) {
Release release = getFirstRelease();
Map<String, FossologyStatus> clearingTeamToFossologyStatus = release.getClearingTeamToFossologyStatus();
clearingTeamToFossologyStatus.put(clearingTeam, fossologyStatus);
the_clearing_state_is_computed_for(lastTestedClearingTeam);
return self();
}
Aggregations