use of org.eclipse.sw360.datahandler.thrift.Source in project sw360portal by sw360.
the class AttachmentContentWrapperTest method testUpdateNonMetadataTouchesAllFields.
public void testUpdateNonMetadataTouchesAllFields() throws Exception {
AttachmentContent source;
source = new AttachmentContent();
source.setFilename("a");
source.setType("b");
source.setContentType("v");
source.setPartsCount("1");
// TODO this is not required !
source.setRemoteUrl("uskt");
AttachmentContentWrapper attachmentContentWrapper = new AttachmentContentWrapper();
attachmentContentWrapper.updateNonMetadata(source);
assertTFields(source, attachmentContentWrapper, AttachmentContentWrapper.class, AttachmentContent._Fields.class);
}
use of org.eclipse.sw360.datahandler.thrift.Source in project sw360portal by sw360.
the class AttachmentHandlerTest method testAttachmentUsageCountWithFilter.
@Test
public void testAttachmentUsageCountWithFilter() throws Exception {
AttachmentUsage usage1 = createUsage("p1", "r1", "a11", UsageData.licenseInfo(new LicenseInfoUsage()));
AttachmentUsage usage2 = createUsage("p1", "r1", "a12");
AttachmentUsage usage3 = createUsage("p2", "r2", "a21", UsageData.licenseInfo(new LicenseInfoUsage()));
AttachmentUsage usage4 = createUsage("p3", "r1", "a11", UsageData.licenseInfo(new LicenseInfoUsage()));
AttachmentUsage usage5 = createUsage("p4", "r1", "a11");
AttachmentUsage usage6 = createUsage("p5", "r3", "a31");
handler.makeAttachmentUsages(Lists.newArrayList(usage1, usage2, usage3, usage4, usage5, usage6));
Map<Source, Set<String>> queryFor = ImmutableMap.of(Source.releaseId("r1"), ImmutableSet.of("a11", "a12"), Source.releaseId("r3"), ImmutableSet.of("a31"));
Map<Map<Source, String>, Integer> counts = handler.getAttachmentUsageCount(queryFor, UsageData.licenseInfo(new LicenseInfoUsage()));
Map<Map<Source, String>, Integer> expected = ImmutableMap.of(ImmutableMap.of(Source.releaseId("r1"), "a11"), 2);
for (Entry<Map<Source, String>, Integer> entry : expected.entrySet()) {
Assert.assertThat(counts.get(entry.getKey()), is(entry.getValue()));
}
}
use of org.eclipse.sw360.datahandler.thrift.Source in project sw360portal by sw360.
the class DocxGenerator method fillReleaseDetailList.
private void fillReleaseDetailList(XWPFDocument document, Collection<LicenseInfoParsingResult> projectLicenseInfoResults, boolean includeObligations) throws TException {
addFormattedText(document.createParagraph().createRun(), "Detailed Releases Information", FONT_SIZE + 2, true);
setText(document.createParagraph().createRun(), "Please note the following license conditions and copyright " + "notices applicable to Open Source Software and/or other components (or parts thereof):");
addNewLines(document, 0);
for (LicenseInfoParsingResult parsingResult : projectLicenseInfoResults) {
addReleaseTitle(document, parsingResult);
if (parsingResult.getStatus() == LicenseInfoRequestStatus.SUCCESS) {
addCopyrights(document, parsingResult);
addLicenses(document, parsingResult, includeObligations);
} else {
XWPFRun errorRun = document.createParagraph().createRun();
String errorText = nullToEmptyString(parsingResult.getMessage());
String filename = getFilename(parsingResult);
addFormattedText(errorRun, String.format("Error reading license information: %s", errorText), FONT_SIZE, false, ALERT_COLOR);
addFormattedText(errorRun, String.format("Source file: %s", filename), FONT_SIZE, false, ALERT_COLOR);
}
addNewLines(document, 1);
}
addPageBreak(document);
}
use of org.eclipse.sw360.datahandler.thrift.Source in project sw360portal by sw360.
the class ComponentCSVRecord method getRelease.
public Release getRelease(String vendorId, String componentId, List<AttachmentContent> attachments) {
Release release = new Release();
// required
release.setName(releaseName).setVersion(releaseVersion).setComponentId(componentId);
// optionals
if (!isNullOrEmpty(vendorId)) {
release.setVendorId(vendorId);
}
if (!isNullOrEmpty(CPEId)) {
release.setCpeid(CPEId);
}
if (!isNullOrEmpty(releaseDate)) {
release.setReleaseDate(releaseDate);
}
if (!isNullOrEmpty(releaseCreatedOn)) {
release.setCreatedOn(releaseCreatedOn);
}
if (!isNullOrEmpty(releaseCreatedBy)) {
release.setCreatedBy(releaseCreatedBy);
}
if (CommonUtils.isValidUrl(releaseDownloadURL)) {
release.setDownloadurl(releaseDownloadURL);
}
if (isSetRepository()) {
release.setRepository(getRepository());
}
if (!isNullOrEmpty(releaseMainlineState)) {
final MainlineState mainlineState = ThriftEnumUtils.stringToEnum(releaseMainlineState, MainlineState.class);
if (mainlineState != null)
release.setMainlineState(mainlineState);
}
if (!isNullOrEmpty(releaseClearingState)) {
final ClearingState clearingState = ThriftEnumUtils.stringToEnum(releaseClearingState, ClearingState.class);
if (clearingState != null)
release.setClearingState(clearingState);
}
if (!isNullOrEmpty(releaseContributors)) {
release.setContributors(CommonUtils.splitToSet(releaseContributors));
}
if (!isNullOrEmpty(releaseModerators)) {
release.setModerators(CommonUtils.splitToSet(releaseModerators));
}
if (!isNullOrEmpty(releaseSubscribers)) {
release.setSubscribers(CommonUtils.splitToSet(releaseSubscribers));
}
if (!isNullOrEmpty(releaseLanguages)) {
release.setLanguages(CommonUtils.splitToSet(releaseLanguages));
}
if (!isNullOrEmpty(releaseOperatingSystems)) {
release.setOperatingSystems(CommonUtils.splitToSet(releaseOperatingSystems));
}
if (!isNullOrEmpty(releaseMainLicenseIds)) {
release.setMainLicenseIds(CommonUtils.splitToSet(releaseMainLicenseIds));
}
if (isSetClearingInformation()) {
release.setClearingInformation(getClearingInformation());
}
if (isSetEccInformation()) {
release.setEccInformation(getEccInformation());
}
// TODO: There should be only one SOURCE per Release
if (attachments != null) {
for (AttachmentContent attachmentContent : attachments) {
String attachmentContentId = attachmentContent.getId();
release.addToAttachments(new Attachment().setAttachmentContentId(attachmentContentId).setCreatedOn(SW360Utils.getCreatedOn()).setCreatedBy(releaseCreatedBy).setAttachmentType(AttachmentType.SOURCE).setFilename(attachmentContent.getFilename()));
}
}
return release;
}
Aggregations