/** * @return {@link NamespacedEntityId} to which the {@link Record} belongs if it is a known cdap entity type for * example datasets, applications etc. Custom resources likes fields etc cannot be converted into cdap * {@link NamespacedEntityId} and calling this for {@link Record} associated with such resources will fail with * a {@link IllegalArgumentException}. * @throws IllegalArgumentException if the {@link Record} belong to a custom cdap resource and not a known cdap * entity. */ public NamespacedEntityId getEntityId() { return EntityId.fromMetadataEntity(metadataEntity); }
/** * @return {@link NamespacedEntityId} to which the {@link Metadata} belongs if it is a known cdap entity type for * example datasets, applications etc. Custom resources likes fields etc cannot be converted into cdap * {@link NamespacedEntityId} and calling this for {@link Metadata} associated with such resources will fail with a * {@link IllegalArgumentException}. * @throws IllegalArgumentException if the {@link Metadata} belong to a custom cdap resource and not a known cdap * entity. */ public NamespacedEntityId getEntityId() { return EntityId.fromMetadataEntity(metadataEntity); }
public NamespacedEntityId getEntityId() { return EntityId.fromMetadataEntity(metadataEntity); }
public NamespacedEntityId getEntityId() { return EntityId.fromMetadataEntity(metadataEntity); }
/** * @return An {@link Optional} which contains {@link MetadataRecord} if the given metadataRecordV2 is compatible i.e. * the record do not represent a custom entity else is absent. */ @VisibleForTesting static Optional<MetadataRecord> makeCompatible(MetadataRecordV2 metadataRecordV2) { MetadataEntity metadataEntity = metadataRecordV2.getMetadataEntity(); try { NamespacedEntityId entityId = EntityId.fromMetadataEntity(metadataEntity); return Optional.of(new MetadataRecord(entityId, metadataRecordV2.getScope(), metadataRecordV2.getProperties(), metadataRecordV2.getTags())); } catch (IllegalArgumentException e) { // ignore the custom entities for backward compatibility return Optional.empty(); } }
private Set<MetadataRecord> getMetadata(MetadataEntity metadataEntity, @Nullable String scope, boolean aggregateRun) throws BadRequestException { // the lineage admin handles the metadata call for program runs so delegate the call to that Set<MetadataRecord> metadata; if (aggregateRun && metadataEntity.getType().equals(MetadataEntity.PROGRAM_RUN)) { // CDAP-13721 for backward compatibility we need to support metadata aggregation of runId. metadata = lineageAdmin.getMetadataForRun(EntityId.fromMetadataEntity(metadataEntity)); } else { if (scope == null) { metadata = metadataAdmin.getMetadata(metadataEntity); } else { metadata = metadataAdmin.getMetadata(validateScope(scope), metadataEntity); } } return metadata; }
private Optional<MetadataEntry> parseRow(Row rowToProcess, String indexColumn, Set<EntityTypeSimpleName> entityFilter, boolean showHidden) { String rowValue = rowToProcess.getString(indexColumn); if (rowValue == null) { return Optional.empty(); } final byte[] rowKey = rowToProcess.getRow(); String targetType = MetadataKey.extractTargetType(rowKey); // Filter on target type if not set to include all types boolean includeAllTypes = entityFilter.isEmpty() || entityFilter.contains(EntityTypeSimpleName.ALL); if (!includeAllTypes && !entityFilter.contains(EntityTypeSimpleName.valueOfSerializedForm(targetType))) { return Optional.empty(); } MetadataEntity metadataEntity = MetadataKey.extractMetadataEntityFromKey(rowKey); try { NamespacedEntityId namespacedEntityId = EntityId.fromMetadataEntity(metadataEntity); // if the entity starts with _ then skip it unless the caller choose to showHidden. if (!showHidden && namespacedEntityId != null && namespacedEntityId.getEntityName().startsWith("_")) { return Optional.empty(); } } catch (IllegalArgumentException e) { // ignore. For custom entities we don't really want to hide them if they start with _ } String key = MetadataKey.extractMetadataKey(rowKey); MetadataEntry entry = getMetadata(metadataEntity, key); return Optional.ofNullable(entry); }
private Set<MetadataRecordV2> getMetadata(MetadataEntity metadataEntity, @Nullable String scope, boolean aggregateRun) throws BadRequestException { // the lineage admin handles the metadata call for program runs so delegate the call to that Set<MetadataRecordV2> metadata; if (aggregateRun && metadataEntity.getType().equals(MetadataEntity.PROGRAM_RUN)) { // CDAP-13721 for backward compatibility we need to support metadata aggregation of runId. metadata = lineageAdmin.getMetadataForRun(EntityId.fromMetadataEntity(metadataEntity)); } else { if (scope == null) { metadata = metadataAdmin.getMetadata(metadataEntity); } else { metadata = metadataAdmin.getMetadata(validateScope(scope), metadataEntity); } } return metadata; }
private Optional<MetadataEntry> parseRow(Row rowToProcess, String indexColumn, Set<EntityTypeSimpleName> entityFilter, boolean showHidden) { String rowValue = rowToProcess.getString(indexColumn); if (rowValue == null) { return Optional.empty(); } final byte[] rowKey = rowToProcess.getRow(); String targetType = MetadataKey.extractTargetType(rowKey); // Filter on target type if not set to include all types boolean includeAllTypes = entityFilter.isEmpty() || entityFilter.contains(EntityTypeSimpleName.ALL); if (!includeAllTypes && !entityFilter.contains(EntityTypeSimpleName.valueOfSerializedForm(targetType))) { return Optional.empty(); } MetadataEntity metadataEntity = MetadataKey.extractMetadataEntityFromKey(rowKey); try { NamespacedEntityId namespacedEntityId = EntityId.fromMetadataEntity(metadataEntity); // if the entity starts with _ then skip it unless the caller choose to showHidden. if (!showHidden && namespacedEntityId != null && namespacedEntityId.getEntityName().startsWith("_")) { return Optional.empty(); } } catch (IllegalArgumentException e) { // ignore. For custom entities we don't really want to hide them if they start with _ } String key = MetadataKey.extractMetadataKey(rowKey); MetadataEntry entry = getMetadata(metadataEntity, key); return Optional.ofNullable(entry); }
EntityId entityId = EntityId.fromMetadataEntity(metadataEntity); Set<MetadataRecord> metadata = scope == null ? client.getMetadata(entityId) : client.getMetadata(entityId, MetadataScope.valueOf(scope.toUpperCase()));
/** * Filters the given metadataSearchResponseV2 for backward compatibility by dropping entries for custom entity. * * @param metadataSearchResponseV2 the {@link MetadataSearchResponseV2} to be filtered * @return {@link MetadataSearchResponse} which does not contain records for custom entities. */ public static MetadataSearchResponse makeCompatible(MetadataSearchResponseV2 metadataSearchResponseV2) { // use linked hashset since the search response is ordered and we want to maintain the ordering Set<MetadataSearchResultRecord> filteredResults = new LinkedHashSet<>(); Set<MetadataSearchResultRecordV2> results = metadataSearchResponseV2.getResults(); results.forEach(record -> { try { NamespacedEntityId entityId = EntityId.fromMetadataEntity(record.getMetadataEntity()); filteredResults.add(new MetadataSearchResultRecord(entityId, record.getMetadata())); } catch (IllegalArgumentException e) { // ignore the custom entities for backward compatibility } }); return new MetadataSearchResponse(metadataSearchResponseV2.getSort(), metadataSearchResponseV2.getOffset(), metadataSearchResponseV2.getLimit(), metadataSearchResponseV2.getNumCursors(), metadataSearchResponseV2.getTotal(), filteredResults, metadataSearchResponseV2.getCursors(), metadataSearchResponseV2.isShowHidden(), metadataSearchResponseV2.getEntityScope()); } }
metadataEntity = EntityId.fromMetadataEntity(metadataEntity).toMetadataEntity();
metadataEntity = EntityId.fromMetadataEntity(metadataEntity).toMetadataEntity();
Multimap<AuditType, EntityId> actualAuditEntities = HashMultimap.create(); for (AuditMessage message : publishedMessages) { EntityId entityId = EntityId.fromMetadataEntity(message.getEntity()); if (entityId instanceof NamespacedEntityId) { if (((NamespacedEntityId) entityId).getNamespace().equals(NamespaceId.SYSTEM.getNamespace())) {