use of org.eclipse.sw360.datahandler.thrift.MainlineState 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.MainlineState in project sw360portal by sw360.
the class JsonReleaseRelationSerializer method serialize.
@Override
public void serialize(Map<String, ProjectReleaseRelationship> releaseRelationMap, JsonGenerator gen, SerializerProvider provider) throws IOException, JsonProcessingException {
List<Map<String, String>> linkedReleases = new ArrayList<>();
for (Map.Entry<String, ProjectReleaseRelationship> releaseRelation : releaseRelationMap.entrySet()) {
String releaseLink = linkTo(ProjectController.class).slash("api" + ReleaseController.RELEASES_URL + "/" + releaseRelation.getKey()).withSelfRel().getHref();
Map<String, String> linkedRelease = new HashMap<>();
ProjectReleaseRelationship projectReleaseRelationship = releaseRelation.getValue();
linkedRelease.put("relation", projectReleaseRelationship.getReleaseRelation().name());
linkedRelease.put("mainlineState", projectReleaseRelationship.getMainlineState().name());
linkedRelease.put("release", releaseLink);
linkedReleases.add(linkedRelease);
}
gen.writeObject(linkedReleases);
}
Aggregations