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();
}
}
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;
}
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;
}
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;
}
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;
}
Aggregations