Search in sources :

Example 91 with Release._Fields

use of org.eclipse.sw360.datahandler.thrift.components.Release._Fields in project sw360portal by sw360.

the class SW360Utils method setVendorId.

/**
 * Set the vendor id if the vendor object is set
 */
public static void setVendorId(Release release) {
    // Save the vendor ID, not its contents
    if (release.isSetVendor()) {
        Vendor vendor = release.getVendor();
        release.setVendorId(vendor.getId());
        release.unsetVendor();
    }
    if (isNullOrEmpty(release.getVendorId())) {
        release.unsetVendorId();
    }
}
Also used : Vendor(org.eclipse.sw360.datahandler.thrift.vendors.Vendor)

Example 92 with Release._Fields

use of org.eclipse.sw360.datahandler.thrift.components.Release._Fields in project hive by apache.

the class ColumnStatsMergerFactory method getColumnStatsMerger.

public static ColumnStatsMerger getColumnStatsMerger(ColumnStatisticsObj statsObjNew, ColumnStatisticsObj statsObjOld) {
    ColumnStatsMerger agg;
    _Fields typeNew = statsObjNew.getStatsData().getSetField();
    _Fields typeOld = statsObjOld.getStatsData().getSetField();
    // make sure that they have the same type
    typeNew = typeNew == typeOld ? typeNew : null;
    int numBitVectors = 0;
    switch(typeNew) {
        case BOOLEAN_STATS:
            agg = new BooleanColumnStatsMerger();
            break;
        case LONG_STATS:
            {
                agg = new LongColumnStatsMerger();
                int nbvNew = countNumBitVectors(statsObjNew.getStatsData().getLongStats().getBitVectors());
                int nbvOld = countNumBitVectors(statsObjOld.getStatsData().getLongStats().getBitVectors());
                numBitVectors = nbvNew == nbvOld ? nbvNew : 0;
                break;
            }
        case DOUBLE_STATS:
            {
                agg = new DoubleColumnStatsMerger();
                int nbvNew = countNumBitVectors(statsObjNew.getStatsData().getDoubleStats().getBitVectors());
                int nbvOld = countNumBitVectors(statsObjOld.getStatsData().getDoubleStats().getBitVectors());
                numBitVectors = nbvNew == nbvOld ? nbvNew : 0;
                break;
            }
        case STRING_STATS:
            {
                agg = new StringColumnStatsMerger();
                int nbvNew = countNumBitVectors(statsObjNew.getStatsData().getStringStats().getBitVectors());
                int nbvOld = countNumBitVectors(statsObjOld.getStatsData().getStringStats().getBitVectors());
                numBitVectors = nbvNew == nbvOld ? nbvNew : 0;
                break;
            }
        case BINARY_STATS:
            agg = new BinaryColumnStatsMerger();
            break;
        case DECIMAL_STATS:
            {
                agg = new DecimalColumnStatsMerger();
                int nbvNew = countNumBitVectors(statsObjNew.getStatsData().getDecimalStats().getBitVectors());
                int nbvOld = countNumBitVectors(statsObjOld.getStatsData().getDecimalStats().getBitVectors());
                numBitVectors = nbvNew == nbvOld ? nbvNew : 0;
                break;
            }
        default:
            throw new RuntimeException("Woh, bad.  Unknown stats type " + typeNew.toString());
    }
    if (numBitVectors > 0) {
        agg.ndvEstimator = new NumDistinctValueEstimator(numBitVectors);
    }
    return agg;
}
Also used : ColumnStatisticsData._Fields(org.apache.hadoop.hive.metastore.api.ColumnStatisticsData._Fields) NumDistinctValueEstimator(org.apache.hadoop.hive.metastore.NumDistinctValueEstimator)

Example 93 with Release._Fields

use of org.eclipse.sw360.datahandler.thrift.components.Release._Fields 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 94 with Release._Fields

use of org.eclipse.sw360.datahandler.thrift.components.Release._Fields 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)

Example 95 with Release._Fields

use of org.eclipse.sw360.datahandler.thrift.components.Release._Fields in project sw360portal by sw360.

the class ReleaseSummary method summary.

protected Release summary(SummaryType type, Release document, Function<String, Vendor> vendorProvider) {
    Release copy = new Release();
    if (type == SummaryType.DETAILED_EXPORT_SUMMARY) {
        setDetailedExportSummaryFields(document, copy);
    } else {
        setShortSummaryFields(document, copy);
        if (type != SummaryType.SHORT) {
            setAdditionalFieldsForSummariesOtherThanShortAndDetailedExport(document, copy);
        }
    }
    if (document.isSetVendorId()) {
        final String vendorId = document.getVendorId();
        if (!Strings.isNullOrEmpty(vendorId)) {
            Vendor vendor = vendorProvider.apply(vendorId);
            copy.setVendor(vendor);
        }
    }
    return copy;
}
Also used : 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)93 User (org.eclipse.sw360.datahandler.thrift.users.User)42 TException (org.apache.thrift.TException)38 Test (org.junit.Test)23 Component (org.eclipse.sw360.datahandler.thrift.components.Component)20 ComponentService (org.eclipse.sw360.datahandler.thrift.components.ComponentService)20 Attachment (org.eclipse.sw360.datahandler.thrift.attachments.Attachment)17 RequestStatus (org.eclipse.sw360.datahandler.thrift.RequestStatus)13 Vendor (org.eclipse.sw360.datahandler.thrift.vendors.Vendor)13 Project (org.eclipse.sw360.datahandler.thrift.projects.Project)12 FieldMetaData (org.apache.thrift.meta_data.FieldMetaData)11 FossologyStatus (org.eclipse.sw360.datahandler.thrift.components.FossologyStatus)11 TestUtils.assertTestString (org.eclipse.sw360.datahandler.TestUtils.assertTestString)10 AttachmentContent (org.eclipse.sw360.datahandler.thrift.attachments.AttachmentContent)9 HalResource (org.eclipse.sw360.rest.resourceserver.core.HalResource)7 Before (org.junit.Before)7 Collectors (java.util.stream.Collectors)6 WrappedTException (org.eclipse.sw360.datahandler.common.WrappedException.WrappedTException)6 FilledAttachment (org.eclipse.sw360.datahandler.thrift.attachments.FilledAttachment)6 IOException (java.io.IOException)5