Package com.linkedin.data.schema

Examples of com.linkedin.data.schema.NamedDataSchema


  }

  @Override
  public void renderDataModel(String dataModelName, OutputStream out)
  {
    final NamedDataSchema schema = _relationships.getDataModels().get(dataModelName);
    if (schema == null)
    {
      throw new RoutingException(String.format("Data model named '%s' does not exist", dataModelName), 404) ;
    }
View Full Code Here


      {
        relatedSchemas = new HashMap<String, NamedDataSchema>();
        final Iterator<Node<NamedDataSchema>> schemaItr = node.getAdjacency(NamedDataSchema.class).iterator();
        while (schemaItr.hasNext())
        {
          final NamedDataSchema currResource = (NamedDataSchema) schemaItr.next().getObject();
          relatedSchemas.put(currResource.getFullName(), currResource);
        }
        _relatedSchemaCache.put(parent, relatedSchemas);
      }
    }
View Full Code Here

    {
      String fullName = entry.getKey();
      DataSchemaLocation location = entry.getValue();
      if (_sourceLocations.contains(location) || _sources.contains(fullName))
      {
        NamedDataSchema schema = nameToSchema.get(fullName);
        if (schema instanceof RecordDataSchema)
        {
          RecordDataSchema recordDataSchema = (RecordDataSchema) schema;
          File generatedFile = fileForAvroSchema(fullName, targetDirectory);
          generatedFiles.add(generatedFile);
View Full Code Here

  }

  @Override
  public NamedDataSchema findDataSchema(String name, StringBuilder errorMessageBuilder)
  {
    NamedDataSchema found = existingDataSchema(name);
    if (found == null)
    {
      found = locateDataSchema(name, errorMessageBuilder);
    }
    return found;
View Full Code Here

  }

  @Override
  public NamedDataSchema existingDataSchema(String name)
  {
    NamedDataSchema found = _nameToDataSchema.get(name);
    return found;
  }
View Full Code Here

  @Override
  public void bindNameToSchema(Name name, NamedDataSchema schema, DataSchemaLocation location)
  {
    String fullName = name.getFullName();
    NamedDataSchema replaced = _nameToDataSchema.put(fullName, schema);
    if (replaced != null)
      throw new IllegalStateException(fullName + " cannot be refined from " + replaced + " to " + schema);
    _nameToDataSchemaLocations.put(fullName, location);
    _resolvedLocations.add(location);
  }
View Full Code Here

   * @param errorMessageBuilder to append error messages to.
   * @return the NamedDataSchema if it can be located, else return null.
   */
  protected NamedDataSchema locateDataSchema(String name, StringBuilder errorMessageBuilder)
  {
    NamedDataSchema schema = null;
    Iterator<DataSchemaLocation> locations = possibleLocations(name);
    while (locations.hasNext())
    {
      DataSchemaLocation location = locations.next();
      if (location == null || isBadLocation(location))
View Full Code Here

   * @param errorMessageBuilder to append error messages to.
   * @return the {@link NamedDataSchema} is found in the input stream, else return null.
   */
  protected NamedDataSchema parse(InputStream inputStream, final DataSchemaLocation location, String name, StringBuilder errorMessageBuilder)
  {
    NamedDataSchema schema = null;
    SchemaParser parser = _parserFactory.create(this);
    parser.setLocation(location);
    //out.println("start parsing " + location);

    parser.parse(new FilterInputStream(inputStream)
View Full Code Here

   */
  private void validateSchemaWithFilepath(File schemaSourceFile, DataSchema schema)
  {
    if(schemaSourceFile != null && schemaSourceFile.isFile() && schema instanceof NamedDataSchema)
    {
      NamedDataSchema namedDataSchema = (NamedDataSchema)schema;
      String namespace = namedDataSchema.getNamespace();

      if(!removeFileExtension(schemaSourceFile.getName()).equalsIgnoreCase(namedDataSchema.getName()))
      {
        throw new IllegalArgumentException(namedDataSchema.getFullName() + " has name that does not match filename '" +
                schemaSourceFile.getAbsolutePath() + "'");
      }

      String directory = schemaSourceFile.getParentFile().getAbsolutePath();
      if(!directory.endsWith(namespace.replace('.', File.separatorChar)))
      {
        throw new IllegalArgumentException(namedDataSchema.getFullName() + " has namespace that does not match " +
                "file path '" + schemaSourceFile.getAbsolutePath() + "'");
      }
    }
  }
View Full Code Here

      ArrayList<File> generatedFiles = new ArrayList<File>(schemas.size());
      for (DataSchema schema : schemas)
      {
        if (schema instanceof NamedDataSchema)
        {
          NamedDataSchema namedDataSchema = (NamedDataSchema) schema;
          String fullName = namedDataSchema.getFullName();
          File generatedFile = fileForAvroSchema(fullName, targetDirectory);
          generatedFiles.add(generatedFile);
        }
      }
      return generatedFiles;
View Full Code Here

TOP

Related Classes of com.linkedin.data.schema.NamedDataSchema

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.