Tabnine Logo
MetadataEntity$Builder.append
Code IndexAdd Tabnine to your IDE (free)

How to use
append
method
in
co.cask.cdap.api.metadata.MetadataEntity$Builder

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

origin: cdapio/cdap

private MetadataEntity.Builder appendHelper(MetadataEntity.Builder builder, @Nullable String entityType,
                  String key, String value) {
 if (entityType == null || entityType.isEmpty()) {
  // if a type is not provided then keep appending as type to update the type on every append
  return builder.appendAsType(key, value);
 } else {
  if (entityType.equalsIgnoreCase(key)) {
   // if a type was provided and this key is the type then appendAsType
   return builder.appendAsType(key, value);
  } else {
   return builder.append(key, value);
  }
 }
}
origin: co.cask.cdap/cdap-app-fabric

private MetadataEntity.Builder appendHelper(MetadataEntity.Builder builder, @Nullable String entityType,
                  String key, String value) {
 if (entityType == null || entityType.isEmpty()) {
  // if a type is not provided then keep appending as type to update the type on every append
  return builder.appendAsType(key, value);
 } else {
  if (entityType.equalsIgnoreCase(key)) {
   // if a type was provided and this key is the type then appendAsType
   return builder.appendAsType(key, value);
  } else {
   return builder.append(key, value);
  }
 }
}
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: cdapio/cdap

@Test
public void testMakeBackwardCompatible() {
 MetadataEntity.Builder entity = MetadataEntity.builder().append(MetadataEntity.NAMESPACE, "ns")
  .append(MetadataEntity.APPLICATION, "app")
  .append(MetadataEntity.VERSION, "ver");
 MetadataEntity expected = MetadataEntity.builder().append(MetadataEntity.NAMESPACE, "ns")
  .appendAsType(MetadataEntity.APPLICATION, "app")
  .append(MetadataEntity.VERSION, "ver").build();
 Assert.assertEquals(expected, actual.build());
 entity = MetadataEntity.builder().append(MetadataEntity.NAMESPACE, "ns")
  .append(MetadataEntity.ARTIFACT, "art")
  .append(MetadataEntity.VERSION, "ver");
 expected = MetadataEntity.builder().append(MetadataEntity.NAMESPACE, "ns")
  .appendAsType(MetadataEntity.ARTIFACT, "art")
  .append(MetadataEntity.VERSION, "ver").build();
 Assert.assertEquals(expected, actual.build());
 entity = MetadataEntity.builder().append(MetadataEntity.NAMESPACE, "ns")
  .append(MetadataEntity.APPLICATION, "app");
 actual = MetadataHttpHandler.makeBackwardCompatible(entity);
 expected = MetadataEntity.builder().append(MetadataEntity.NAMESPACE, "ns")
  .appendAsType(MetadataEntity.APPLICATION, "app").build();
 Assert.assertEquals(expected, actual.build());
origin: caskdata/cdap

private static MetadataEntity fromCliString(String cliString) {
 String[] keyValues = cliString.split(METADATA_ENTITY_PARTS_SEPARATOR);
 int lastKeyValueIndex = keyValues.length - 1;
 MetadataEntity.Builder builder = MetadataEntity.builder();
 String customType = null;
 if (getKeyValue(keyValues[lastKeyValueIndex])[0].equalsIgnoreCase(METADATA_ENTITY_TYPE)) {
  // if a type is specified then store it to call appendAsType later
  customType = getKeyValue(keyValues[lastKeyValueIndex])[1];
  lastKeyValueIndex -= 1;
 }
 for (int i = 0; i <= lastKeyValueIndex; i++) {
  String[] part = getKeyValue(keyValues[i]);
  if (part[0].equals(customType)) {
   builder.appendAsType(part[0], part[1]);
  } else {
   builder.append(part[0], part[1]);
  }
 }
 return builder.build();
}
origin: co.cask.cdap/cdap-cli

private static MetadataEntity fromCliString(String cliString) {
 String[] keyValues = cliString.split(METADATA_ENTITY_PARTS_SEPARATOR);
 int lastKeyValueIndex = keyValues.length - 1;
 MetadataEntity.Builder builder = MetadataEntity.builder();
 String customType = null;
 if (getKeyValue(keyValues[lastKeyValueIndex])[0].equalsIgnoreCase(METADATA_ENTITY_TYPE)) {
  // if a type is specified then store it to call appendAsType later
  customType = getKeyValue(keyValues[lastKeyValueIndex])[1];
  lastKeyValueIndex -= 1;
 }
 for (int i = 0; i <= lastKeyValueIndex; i++) {
  String[] part = getKeyValue(keyValues[i]);
  if (part[0].equals(customType)) {
   builder.appendAsType(part[0], part[1]);
  } else {
   builder.append(part[0], part[1]);
  }
 }
 return builder.build();
}
origin: co.cask.cdap/cdap-proto

@Override
public MetadataEntity toMetadataEntity() {
 return MetadataEntity.builder().append(MetadataEntity.NAMESPACE, namespace).append(MetadataEntity.STREAM, stream)
  .appendAsType(MetadataEntity.VIEW, view)
  .build();
}
origin: co.cask.cdap/cdap-proto

@Override
public MetadataEntity toMetadataEntity() {
 return MetadataEntity.builder().append(MetadataEntity.NAMESPACE, namespace)
  .appendAsType(MetadataEntity.APPLICATION, application)
  .append(MetadataEntity.VERSION, version)
  .build();
}
origin: cdapio/cdap

/**
 * Creates a {@link MetadataEntity} representing the given datasetName in the specified namespace.
 *
 * @param namespace the name of the namespace
 * @param datasetName the name of the dataset
 * @return {@link MetadataEntity} representing the dataset name
 * @throws IllegalArgumentException if the key is a CDAP entity and the MetadataEntity is not correct to represent
 * the CDAP entity
 */
public static MetadataEntity ofDataset(String namespace, String datasetName) {
 return builder().append(MetadataEntity.NAMESPACE, namespace)
  .appendAsType(MetadataEntity.DATASET, datasetName).build();
}
origin: co.cask.cdap/cdap-proto

@Override
public MetadataEntity toMetadataEntity() {
 return MetadataEntity.builder().append(MetadataEntity.NAMESPACE, namespace)
  .append(MetadataEntity.APPLICATION, application).append(MetadataEntity.VERSION, version)
  .append(MetadataEntity.FLOW, flow).appendAsType(MetadataEntity.FLOWLET, flowlet)
  .build();
}
origin: caskdata/cdap

@Override
public MetadataEntity toMetadataEntity() {
 return MetadataEntity.builder().append(MetadataEntity.NAMESPACE, namespace)
  .append(MetadataEntity.APPLICATION, application).append(MetadataEntity.VERSION, version)
  .appendAsType(MetadataEntity.SCHEDULE, schedule)
  .build();
}
origin: caskdata/cdap

@Override
public MetadataEntity toMetadataEntity() {
 return MetadataEntity.builder().append(MetadataEntity.NAMESPACE, namespace)
  .append(MetadataEntity.APPLICATION, application)
  .append(MetadataEntity.VERSION, version).append(MetadataEntity.TYPE, type.getPrettyName())
  .appendAsType(MetadataEntity.PROGRAM, program)
  .build();
}
origin: co.cask.cdap/cdap-proto

@Override
public MetadataEntity toMetadataEntity() {
 return MetadataEntity.builder().append(MetadataEntity.NAMESPACE, namespace)
  .append(MetadataEntity.APPLICATION, application)
  .append(MetadataEntity.VERSION, version).append(MetadataEntity.TYPE, type.getPrettyName())
  .appendAsType(MetadataEntity.PROGRAM, program)
  .build();
}
origin: co.cask.cdap/cdap-proto

@Override
public MetadataEntity toMetadataEntity() {
 return MetadataEntity.builder().append(MetadataEntity.NAMESPACE, namespace)
  .append(MetadataEntity.APPLICATION, application).append(MetadataEntity.VERSION, version)
  .appendAsType(MetadataEntity.SCHEDULE, schedule)
  .build();
}
origin: co.cask.cdap/cdap-proto

@Override
public MetadataEntity toMetadataEntity() {
 return MetadataEntity.builder().append(MetadataEntity.NAMESPACE, namespace)
  .appendAsType(MetadataEntity.ARTIFACT, artifact)
  .append(MetadataEntity.VERSION, version)
  .build();
}
origin: co.cask.cdap/cdap-proto

@Override
public MetadataEntity toMetadataEntity() {
 return MetadataEntity.builder().append(MetadataEntity.NAMESPACE, namespace)
  .appendAsType(MetadataEntity.STREAM, stream)
  .build();
}
origin: co.cask.cdap/cdap-proto

@Override
public MetadataEntity toMetadataEntity() {
 return MetadataEntity.builder().append(MetadataEntity.NAMESPACE, namespace)
  .append(MetadataEntity.APPLICATION, application)
  .append(MetadataEntity.VERSION, version).append(MetadataEntity.TYPE, type.getPrettyName())
  .append(MetadataEntity.PROGRAM, program)
  .appendAsType(MetadataEntity.PROGRAM_RUN, run)
  .build();
}
origin: caskdata/cdap

@Override
public MetadataEntity toMetadataEntity() {
 return MetadataEntity.builder().append(MetadataEntity.NAMESPACE, namespace)
  .appendAsType(MetadataEntity.APPLICATION, application)
  .append(MetadataEntity.VERSION, version)
  .build();
}
origin: caskdata/cdap

@Override
public MetadataEntity toMetadataEntity() {
 return MetadataEntity.builder().append(MetadataEntity.NAMESPACE, namespace)
  .append(MetadataEntity.APPLICATION, application)
  .append(MetadataEntity.VERSION, version).append(MetadataEntity.TYPE, type.getPrettyName())
  .append(MetadataEntity.PROGRAM, program)
  .appendAsType(MetadataEntity.PROGRAM_RUN, run)
  .build();
}
origin: caskdata/cdap

@Override
public MetadataEntity toMetadataEntity() {
 return MetadataEntity.builder().append(MetadataEntity.NAMESPACE, namespace)
  .appendAsType(MetadataEntity.ARTIFACT, artifact)
  .append(MetadataEntity.VERSION, version)
  .build();
}
co.cask.cdap.api.metadataMetadataEntity$Builderappend

Javadoc

Put the given key (case insensitive) with the given value in MetadataEntity.Builder. The returned MetadataEntity.Builder is of the same type. If the type needs to changed during append then #appendAsType(String,String) should be used.

Popular methods of MetadataEntity$Builder

  • appendAsType
  • build
  • <init>
  • validateHierarchy
  • validateKey

Popular in Java

  • Start an intent from android
  • startActivity (Activity)
  • onRequestPermissionsResult (Fragment)
  • requestLocationUpdates (LocationManager)
  • Socket (java.net)
    Provides a client-side TCP socket.
  • Path (java.nio.file)
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • Queue (java.util)
    A collection designed for holding elements prior to processing. Besides basic java.util.Collection o
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • Top PhpStorm plugins
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