congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
MetadataEntity.getType
Code IndexAdd Tabnine to your IDE (free)

How to use
getType
method
in
co.cask.cdap.api.metadata.MetadataEntity

Best Java code snippets using co.cask.cdap.api.metadata.MetadataEntity.getType (Showing top 20 results out of 315)

origin: cdapio/cdap

/**
 * @return a {@link String} which describes the {@link MetadataEntity} for a user in plain english.
 * If the {@link MetadataEntity} represents a known CDAP entity then the description is worded to show relations
 * in the hierarchy.
 */
public String getDescription() {
 return getDescription(new StringBuilder(), getType());
}
origin: cdapio/cdap

@Override
public Set<String> getIndexes(MetadataEntry entry) {
 Set<String> indexes = new HashSet<>();
 indexes.add(entry.getMetadataEntity().getType() + MetadataConstants.KEYVALUE_SEPARATOR +
        entry.getMetadataEntity().getValue(entry.getMetadataEntity().getType()));
 return indexes;
}
origin: caskdata/cdap

 private String addQueryParams(String path, MetadataEntity metadataEntity, @Nullable  MetadataScope scope,
                boolean aggregateRun) {
  StringBuilder builder = new StringBuilder(path);
  String prefix = "?";
  if (!Iterables.getLast(metadataEntity.getKeys()).equalsIgnoreCase(metadataEntity.getType())) {
   // if last leaf node is not the entity type specify it through query para
   builder.append(prefix);
   builder.append("type=");
   builder.append(metadataEntity.getType());
   prefix = "&";
  }
  // the default value of aggregateRun is true so in the case it is false we need to include it as query param
  if (!aggregateRun) {
   builder.append(prefix);
   builder.append("aggregateRun=");
   builder.append(false);
   prefix = "&";
  }
  if (scope == null) {
   return builder.toString();
  } else {
   builder.append(prefix);
   builder.append("scope=");
   builder.append(scope);
  }
  return builder.toString();
 }
}
origin: co.cask.cdap/cdap-data-fabric

@Override
public Set<String> getIndexes(MetadataEntry entry) {
 Set<String> indexes = new HashSet<>();
 indexes.add(entry.getMetadataEntity().getType() + MetadataDataset.KEYVALUE_SEPARATOR +
        entry.getMetadataEntity().getValue(entry.getMetadataEntity().getType()));
 return indexes;
}
origin: caskdata/cdap

/**
 * Returns the EntityId represented by the given MetadataEntity. Note: Custom MetadataEntity cannot be converted
 * into EntityId hence this call is only safe to be called if the MetadataEntity does represent an EntityId and can
 * actually be converted to an EntityId.
 * @param metadataEntity the MetadataEntity which needs to be converted to EntityId
 * @return the EntityId
 * @throws IllegalArgumentException if the metadataEntity does not represent an EntityId and is a custom
 * metadataEntity.
 */
public static <T extends EntityId> T fromMetadataEntity(MetadataEntity metadataEntity) {
 // check that the type of teh metadata entity is known type
 EntityType.valueOf(metadataEntity.getType().toUpperCase());
 return getSelfOrParentEntityId(metadataEntity);
}
origin: co.cask.cdap/cdap-proto

/**
 * Returns the EntityId represented by the given MetadataEntity. Note: Custom MetadataEntity cannot be converted
 * into EntityId hence this call is only safe to be called if the MetadataEntity does represent an EntityId and can
 * actually be converted to an EntityId.
 * @param metadataEntity the MetadataEntity which needs to be converted to EntityId
 * @return the EntityId
 * @throws IllegalArgumentException if the metadataEntity does not represent an EntityId and is a custom
 * metadataEntity.
 */
public static <T extends EntityId> T fromMetadataEntity(MetadataEntity metadataEntity) {
 // check that the type of teh metadata entity is known type
 EntityType.valueOf(metadataEntity.getType().toUpperCase());
 return getSelfOrParentEntityId(metadataEntity);
}
origin: caskdata/cdap

/**
 * Returns a CLI friendly representation of MetadataEntity.
 * For a dataset ds1 in ns1 the EntityId representation will be
 * <pre>dataset:ns1.ds1</pre>
 * It's equivalent MetadataEntity representation will be
 * <pre>MetadataEntity{details={namespace=ns1, dataset=ds1}, type='dataset'}</pre>
 * The CLI friendly representation will be
 * <pre>namespace=ns1,dataset=ds1,type=dataset</pre>
 *
 * Note: It is not necessary to give a type, if a type is not provided the
 * last key-value pair's key in the hierarchy will be considered as the type.
 */
public static String toCliString(MetadataEntity metadataEntity) {
 StringBuilder builder = new StringBuilder();
 for (MetadataEntity.KeyValue keyValue : metadataEntity) {
  builder.append(keyValue.getKey());
  builder.append(METADATA_ENTITY_KV_SEPARATOR);
  builder.append(keyValue.getValue());
  builder.append(METADATA_ENTITY_PARTS_SEPARATOR);
 }
 builder.append(METADATA_ENTITY_TYPE);
 builder.append(METADATA_ENTITY_KV_SEPARATOR);
 builder.append(metadataEntity.getType());
 return builder.toString();
}
origin: co.cask.cdap/cdap-common

StringBuilder builder = new StringBuilder(path);
String prefix = "?";
if (!Iterables.getLast(metadataEntity.getKeys()).equalsIgnoreCase(metadataEntity.getType())) {
 builder.append(metadataEntity.getType());
 prefix = "&";
origin: co.cask.cdap/cdap-cli

/**
 * Returns a CLI friendly representation of MetadataEntity.
 * For a dataset ds1 in ns1 the EntityId representation will be
 * <pre>dataset:ns1.ds1</pre>
 * It's equivalent MetadataEntity representation will be
 * <pre>MetadataEntity{details={namespace=ns1, dataset=ds1}, type='dataset'}</pre>
 * The CLI friendly representation will be
 * <pre>namespace=ns1,dataset=ds1,type=dataset</pre>
 *
 * Note: It is not necessary to give a type, if a type is not provided the
 * last key-value pair's key in the hierarchy will be considered as the type.
 */
public static String toCliString(MetadataEntity metadataEntity) {
 StringBuilder builder = new StringBuilder();
 for (MetadataEntity.KeyValue keyValue : metadataEntity) {
  builder.append(keyValue.getKey());
  builder.append(METADATA_ENTITY_KV_SEPARATOR);
  builder.append(keyValue.getValue());
  builder.append(METADATA_ENTITY_PARTS_SEPARATOR);
 }
 builder.append(METADATA_ENTITY_TYPE);
 builder.append(METADATA_ENTITY_KV_SEPARATOR);
 builder.append(metadataEntity.getType());
 return builder.toString();
}
origin: cdapio/cdap

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;
}
origin: co.cask.cdap/cdap-data-fabric

private static MDSKey.Builder getMDSKeyPrefix(MetadataEntity metadataEntity, byte[] rowPrefix) {
 MDSKey.Builder builder = new MDSKey.Builder();
 builder.add(rowPrefix);
 builder.add(metadataEntity.getType());
 // add all the key value pairs from the metadata entity this is the targetId
 for (MetadataEntity.KeyValue keyValue : metadataEntity) {
  // CDAP-13597 for versioned entities like application, schedule and programs their metadata is not versioned
  if (VERSIONED_ENTITIES.contains(metadataEntity.getType()) &&
   keyValue.getKey().equalsIgnoreCase(MetadataEntity.VERSION)) {
   continue;
  }
  builder.add(keyValue.getKey());
  builder.add(keyValue.getValue());
 }
 return builder;
}
private MetadataKey() {
origin: cdapio/cdap

/**
 * If the MetadataEntity Builder key-value represent an application or artifact which is versioned in CDAP i.e. their
 * metadata entity representation ends with 'version' rather than 'application' or 'artifact' and the type is also
 * set to 'version' then for backward compatibility of rest end points return an updated builder which has the
 * correct type. This is only needed in 5.0 for backward compatibility of the rest endpoint.
 * From 5.0 and later the rest end point must be called with a query parameter which specify the type of the
 * metadata entity if the type is not the last key. (CDAP-13678)
 */
@VisibleForTesting
static MetadataEntity.Builder makeBackwardCompatible(MetadataEntity.Builder builder) {
 MetadataEntity entity = builder.build();
 List<MetadataEntity.KeyValue> entityKeyValues = StreamSupport.stream(entity.spliterator(), false)
  .collect(Collectors.toList());
 if (entityKeyValues.size() == 3 && entity.getType().equals(MetadataEntity.VERSION) &&
  (entityKeyValues.get(1).getKey().equals(MetadataEntity.ARTIFACT) ||
   entityKeyValues.get(1).getKey().equals(MetadataEntity.APPLICATION))) {
  // this is artifact or application so update the builder
  MetadataEntity.Builder actualEntityBuilder = MetadataEntity.builder();
  // namespace
  actualEntityBuilder.append(entityKeyValues.get(0).getKey(), entityKeyValues.get(0).getValue());
  // application or artifact (so append as type)
  actualEntityBuilder.appendAsType(entityKeyValues.get(1).getKey(), entityKeyValues.get(1).getValue());
  // version detail
  actualEntityBuilder.append(entityKeyValues.get(2).getKey(), entityKeyValues.get(2).getValue());
  return actualEntityBuilder;
 }
 return builder;
}
origin: co.cask.cdap/cdap-app-fabric

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;
}
origin: co.cask.cdap/cdap-app-fabric

/**
 * If the MetadataEntity Builder key-value represent an application or artifact which is versioned in CDAP i.e. their
 * metadata entity representation ends with 'version' rather than 'application' or 'artifact' and the type is also
 * set to 'version' then for backward compatibility of rest end points return an updated builder which has the
 * correct type. This is only needed in 5.0 for backward compatibility of the rest endpoint.
 * From 5.0 and later the rest end point must be called with a query parameter which specify the type of the
 * metadata entity if the type is not the last key. (CDAP-13678)
 */
@VisibleForTesting
static MetadataEntity.Builder makeBackwardCompatible(MetadataEntity.Builder builder) {
 MetadataEntity entity = builder.build();
 List<MetadataEntity.KeyValue> entityKeyValues = StreamSupport.stream(entity.spliterator(), false)
  .collect(Collectors.toList());
 if (entityKeyValues.size() == 3 && entity.getType().equals(MetadataEntity.VERSION) &&
  (entityKeyValues.get(1).getKey().equals(MetadataEntity.ARTIFACT) ||
   entityKeyValues.get(1).getKey().equals(MetadataEntity.APPLICATION))) {
  // this is artifact or application so update the builder
  MetadataEntity.Builder actualEntityBuilder = MetadataEntity.builder();
  // namespace
  actualEntityBuilder.append(entityKeyValues.get(0).getKey(), entityKeyValues.get(0).getValue());
  // application or artifact (so append as type)
  actualEntityBuilder.appendAsType(entityKeyValues.get(1).getKey(), entityKeyValues.get(1).getValue());
  // version detail
  actualEntityBuilder.append(entityKeyValues.get(2).getKey(), entityKeyValues.get(2).getValue());
  return actualEntityBuilder;
 }
 return builder;
}
origin: cdapio/cdap

private static MDSKey.Builder getMDSKeyPrefix(MetadataEntity metadataEntity, byte[] rowPrefix) {
 MDSKey.Builder builder = new MDSKey.Builder();
 builder.add(rowPrefix);
 builder.add(metadataEntity.getType());
 // add all the key value pairs from the metadata entity this is the targetId
 for (MetadataEntity.KeyValue keyValue : metadataEntity) {
  // CDAP-13597 for versioned entities like application, schedule and programs their metadata is not versioned
  if (VERSIONED_ENTITIES.contains(metadataEntity.getType()) &&
   keyValue.getKey().equalsIgnoreCase(MetadataEntity.VERSION)) {
   continue;
  }
  builder.add(keyValue.getKey());
  builder.add(keyValue.getValue());
 }
 return builder;
}
private MetadataKey() {
origin: cdapio/cdap

builder.append(String.format(" of type '%s'", getType()));
return builder.toString();
origin: cdapio/cdap

 private static MDSKey.Builder getKeyPart(MetadataEntity metadataEntity) {
  MDSKey.Builder builder = new MDSKey.Builder();
  builder.add(ROW_PREFIX);
  builder.add(metadataEntity.getType());
  for (MetadataEntity.KeyValue keyValue : metadataEntity) {
   builder.add(keyValue.getKey());
   builder.add(keyValue.getValue());
  }
  return builder;
 }
}
origin: co.cask.cdap/cdap-data-fabric

 private static MDSKey.Builder getKeyPart(MetadataEntity metadataEntity) {
  MDSKey.Builder builder = new MDSKey.Builder();
  builder.add(ROW_PREFIX);
  builder.add(metadataEntity.getType());
  for (MetadataEntity.KeyValue keyValue : metadataEntity) {
   builder.add(keyValue.getKey());
   builder.add(keyValue.getValue());
  }
  return builder;
 }
}
origin: cdapio/cdap

if (VERSIONED_ENTITIES.contains(metadataEntity.getType())) {
origin: co.cask.cdap/cdap-data-fabric

if (VERSIONED_ENTITIES.contains(metadataEntity.getType())) {
co.cask.cdap.api.metadataMetadataEntitygetType

Popular methods of MetadataEntity

  • builder
  • ofDataset
  • getValue
  • containsKey
  • getDescription
  • getKeys
  • <init>
  • hashCode
  • head
  • iterator
  • ofNamespace
  • spliterator
  • ofNamespace,
  • spliterator,
  • toString

Popular in Java

  • Reactive rest calls using spring rest template
  • onRequestPermissionsResult (Fragment)
  • findViewById (Activity)
  • compareTo (BigDecimal)
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • TimerTask (java.util)
    The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
  • Notification (javax.management)
  • Servlet (javax.servlet)
    Defines methods that all servlets must implement. A servlet is a small Java program that runs within
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now