use of org.eclipse.sw360.datahandler.thrift.licenses.Todo in project sw360portal by sw360.
the class LicenseDatabaseHandler method fillTodos.
private void fillTodos(List<Todo> todos) {
Set<String> obligationIdsToFetch = new HashSet<>();
for (Todo todo : todos) {
obligationIdsToFetch.addAll(CommonUtils.nullToEmptySet(todo.getObligationDatabaseIds()));
}
Map<String, Obligation> obligationIdMap = null;
if (!obligationIdsToFetch.isEmpty()) {
obligationIdMap = ThriftUtils.getIdMap(getObligationsByIds(obligationIdsToFetch));
}
if (obligationIdMap == null) {
obligationIdMap = Collections.emptyMap();
}
for (Todo todo : todos) {
if (todo.isSetObligationDatabaseIds()) {
for (String id : todo.getObligationDatabaseIds()) {
final Obligation obligation = obligationIdMap.get(id);
if (obligation != null) {
todo.addToObligations(obligation);
}
}
}
todo.setDevelopmentString(todo.isDevelopment() ? "True" : "False");
todo.setDistributionString(todo.isDistribution() ? "True" : "False");
todo.unsetObligationDatabaseIds();
}
for (Todo todo : todos) {
if (!todo.isSetWhitelist()) {
todo.setWhitelist(Collections.emptySet());
}
}
}
use of org.eclipse.sw360.datahandler.thrift.licenses.Todo in project sw360portal by sw360.
the class DocxGenerator method addLicenseObligations.
private void addLicenseObligations(XWPFDocument document, String spdxLicense) throws TException {
List<License> sw360Licenses = getLicenses();
XWPFRun todoTitleRun = document.createParagraph().createRun();
addNewLines(todoTitleRun, 0);
Set<String> todos = getTodosFromLicenses(spdxLicense, sw360Licenses);
addFormattedText(todoTitleRun, "Obligations for license " + spdxLicense + ":", FONT_SIZE, true);
for (String todo : todos) {
XWPFParagraph copyPara = document.createParagraph();
copyPara.setSpacingAfter(0);
XWPFRun todoRun = copyPara.createRun();
setText(todoRun, todo);
addNewLines(todoRun, 1);
}
}
use of org.eclipse.sw360.datahandler.thrift.licenses.Todo 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;
}
use of org.eclipse.sw360.datahandler.thrift.licenses.Todo in project sw360portal by sw360.
the class ConvertRecord method convertTodos.
public static List<Todo> convertTodos(List<CSVRecord> records) {
List<Todo> list = new ArrayList<>(records.size());
for (CSVRecord record : records) {
if (record.size() < 2)
break;
String id = record.get(0);
String text = record.get(1);
Todo todo = new Todo().setTodoId(Integer.parseInt(id)).setText(text);
// Parse boolean values
String developmentString = record.get(2);
if (!"NULL".equals(developmentString)) {
boolean development = parseBoolean(developmentString);
todo.setDevelopment(development);
}
String distributionString = record.get(3);
if (!"NULL".equals(distributionString)) {
boolean distribution = parseBoolean(distributionString);
todo.setDistribution(distribution);
}
if (record.size() >= 5) {
Optional.ofNullable(record.get(4)).filter(json -> !"NULL".equals(json)).map(json -> (Map<String, String>) gson.fromJson(json, new TypeToken<Map<String, String>>() {
}.getType())).ifPresent(todo::setExternalIds);
}
list.add(todo);
}
return list;
}
Aggregations