Search in sources :

Example 1 with SummaryType

use of org.eclipse.sw360.components.summary.SummaryType in project sw360portal by sw360.

the class LicenseTypeSummary method summary.

@Override
protected LicenseType summary(SummaryType type, LicenseType document) {
    // Copy required details
    LicenseType copy = new LicenseType();
    switch(type) {
        case EXPORT_SUMMARY:
            copyField(document, copy, _Fields.LICENSE_TYPE);
            copyField(document, copy, _Fields.LICENSE_TYPE_ID);
            copyField(document, copy, _Fields.ID);
        default:
    }
    return copy;
}
Also used : LicenseType(org.eclipse.sw360.datahandler.thrift.licenses.LicenseType)

Example 2 with SummaryType

use of org.eclipse.sw360.components.summary.SummaryType in project sw360portal by sw360.

the class ModerationRequestSummary method summary.

@Override
protected ModerationRequest summary(SummaryType type, ModerationRequest document) {
    ModerationRequest copy = new ModerationRequest();
    copyField(document, copy, ModerationRequest._Fields.ID);
    copyField(document, copy, ModerationRequest._Fields.DOCUMENT_ID);
    copyField(document, copy, ModerationRequest._Fields.DOCUMENT_TYPE);
    copyField(document, copy, ModerationRequest._Fields.DOCUMENT_NAME);
    copyField(document, copy, ModerationRequest._Fields.MODERATION_STATE);
    copyField(document, copy, ModerationRequest._Fields.REQUESTING_USER);
    copyField(document, copy, ModerationRequest._Fields.MODERATORS);
    copyField(document, copy, ModerationRequest._Fields.TIMESTAMP);
    copyField(document, copy, ModerationRequest._Fields.TIMESTAMP_OF_DECISION);
    copyField(document, copy, ModerationRequest._Fields.REQUESTING_USER_DEPARTMENT);
    copyField(document, copy, ModerationRequest._Fields.COMPONENT_TYPE);
    return copy;
}
Also used : ModerationRequest(org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest)

Example 3 with SummaryType

use of org.eclipse.sw360.components.summary.SummaryType in project sw360portal by sw360.

the class ComponentSummary method summary.

@Override
protected Component summary(SummaryType type, Component document) {
    Component copy = new Component();
    if (type == SummaryType.EXPORT_SUMMARY) {
        List<Release> releases = releaseRepository.getReleasesFromComponentId(document.getId());
        return makeExportSummary(document, releases);
    } else if (type == SummaryType.DETAILED_EXPORT_SUMMARY) {
        List<Release> releases = releaseRepository.getReleasesFromComponentId(document.getId());
        final Map<String, Vendor> vendorsById = ThriftUtils.getIdMap(vendorRepository.getAll());
        for (Release release : releases) {
            if (!release.isSetVendor() && release.isSetVendorId()) {
                release.setVendor(vendorsById.get(release.getVendorId()));
            }
        }
        return makeDetailedExportSummary(document, releases);
    } else if (type == SummaryType.HOME) {
        copyField(document, copy, Component._Fields.ID);
        copyField(document, copy, Component._Fields.DESCRIPTION);
    }
    copyField(document, copy, Component._Fields.ID);
    copyField(document, copy, Component._Fields.NAME);
    copyField(document, copy, Component._Fields.VENDOR_NAMES);
    copyField(document, copy, Component._Fields.COMPONENT_TYPE);
    if (type == SummaryType.SUMMARY) {
        for (Component._Fields field : Component.metaDataMap.keySet()) {
            copyField(document, copy, field);
        }
    }
    return copy;
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) Component(org.eclipse.sw360.datahandler.thrift.components.Component) Release(org.eclipse.sw360.datahandler.thrift.components.Release)

Example 4 with SummaryType

use of org.eclipse.sw360.components.summary.SummaryType in project sw360portal by sw360.

the class LicenseSummary method summary.

@Override
protected License summary(SummaryType type, License document) {
    // Copy required details
    License copy = new License();
    switch(type) {
        case EXPORT_SUMMARY:
            copyField(document, copy, _Fields.GPLV2_COMPAT);
            copyField(document, copy, _Fields.REVIEWDATE);
            copyField(document, copy, _Fields.RISKS);
        case SUMMARY:
            copyField(document, copy, _Fields.LICENSE_TYPE);
        default:
            copyField(document, copy, _Fields.ID);
            copy.setShortname(document.getId());
            copyField(document, copy, _Fields.FULLNAME);
            copyField(document, copy, _Fields.LICENSE_TYPE_DATABASE_ID);
    }
    return copy;
}
Also used : License(org.eclipse.sw360.datahandler.thrift.licenses.License)

Example 5 with SummaryType

use of org.eclipse.sw360.components.summary.SummaryType in project sw360portal by sw360.

the class ReleaseSummary method makeSummary.

@Override
public List<Release> makeSummary(SummaryType type, Collection<Release> fullDocuments) {
    if (fullDocuments == null)
        return Collections.emptyList();
    Set<String> vendorIds = fullDocuments.stream().map(Release::getVendorId).filter(Objects::nonNull).filter(s -> !s.isEmpty()).collect(Collectors.toSet());
    Map<String, Vendor> vendorById = ThriftUtils.getIdMap(vendorRepository.get(vendorIds));
    List<Release> documents = new ArrayList<>(fullDocuments.size());
    for (Release fullDocument : fullDocuments) {
        Release document = summary(type, fullDocument, vendorById::get);
        if (document != null)
            documents.add(document);
    }
    return documents;
}
Also used : ThriftUtils(org.eclipse.sw360.datahandler.thrift.ThriftUtils) Strings(com.google.common.base.Strings) ReleaseExporter(org.eclipse.sw360.exporter.ReleaseExporter) java.util(java.util) VendorRepository(org.eclipse.sw360.datahandler.db.VendorRepository) Release(org.eclipse.sw360.datahandler.thrift.components.Release) ThriftUtils.copyField(org.eclipse.sw360.datahandler.thrift.ThriftUtils.copyField) Vendor(org.eclipse.sw360.datahandler.thrift.vendors.Vendor) Release._Fields(org.eclipse.sw360.datahandler.thrift.components.Release._Fields) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) Vendor(org.eclipse.sw360.datahandler.thrift.vendors.Vendor) Release(org.eclipse.sw360.datahandler.thrift.components.Release)

Aggregations

Release (org.eclipse.sw360.datahandler.thrift.components.Release)3 Vendor (org.eclipse.sw360.datahandler.thrift.vendors.Vendor)2 Strings (com.google.common.base.Strings)1 ImmutableList (com.google.common.collect.ImmutableList)1 java.util (java.util)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 VendorRepository (org.eclipse.sw360.datahandler.db.VendorRepository)1 ThriftUtils (org.eclipse.sw360.datahandler.thrift.ThriftUtils)1 ThriftUtils.copyField (org.eclipse.sw360.datahandler.thrift.ThriftUtils.copyField)1 Component (org.eclipse.sw360.datahandler.thrift.components.Component)1 Release._Fields (org.eclipse.sw360.datahandler.thrift.components.Release._Fields)1 License (org.eclipse.sw360.datahandler.thrift.licenses.License)1 LicenseType (org.eclipse.sw360.datahandler.thrift.licenses.LicenseType)1 ModerationRequest (org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest)1 ReleaseExporter (org.eclipse.sw360.exporter.ReleaseExporter)1