Search in sources :

Example 1 with MainlineState

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;
}
Also used : MainlineState(org.eclipse.sw360.datahandler.thrift.MainlineState) AttachmentContent(org.eclipse.sw360.datahandler.thrift.attachments.AttachmentContent) Attachment(org.eclipse.sw360.datahandler.thrift.attachments.Attachment) CommonUtils.nullToEmptyString(org.eclipse.sw360.datahandler.common.CommonUtils.nullToEmptyString)

Example 2 with MainlineState

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);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ProjectReleaseRelationship(org.eclipse.sw360.datahandler.thrift.ProjectReleaseRelationship) HashMap(java.util.HashMap) Map(java.util.Map) ProjectController(org.eclipse.sw360.rest.resourceserver.project.ProjectController)

Aggregations

ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 CommonUtils.nullToEmptyString (org.eclipse.sw360.datahandler.common.CommonUtils.nullToEmptyString)1 MainlineState (org.eclipse.sw360.datahandler.thrift.MainlineState)1 ProjectReleaseRelationship (org.eclipse.sw360.datahandler.thrift.ProjectReleaseRelationship)1 Attachment (org.eclipse.sw360.datahandler.thrift.attachments.Attachment)1 AttachmentContent (org.eclipse.sw360.datahandler.thrift.attachments.AttachmentContent)1 ProjectController (org.eclipse.sw360.rest.resourceserver.project.ProjectController)1