using { my.bookshop, CatalogService } from '{{{basePackage}}}';

namespace {{{extensionNamespace}}};

// new entity
entity x_Authors {
  key ID : Integer;
  name   : String @title : 'Name';
  books  : Association to many bookshop.Books on books.x_author = $self;
}

// field extension incl. association
extend bookshop.Books with {
  x_isbn   : String @title : 'ISBN';
  x_author : Association to x_Authors @title : 'Author';
}

// service extension
extend service CatalogService with {
  @readonly entity Authors as projection on x_Authors;
}

// -------------------------------------------
// Fiori Annotations

annotate CatalogService.Books with @(
  Common.SemanticKey: [x_isbn],
  UI: {
    LineItem: [
      { Value:  x_isbn },
      ... up to { Value: title },
      { Value:  x_author_ID },
      ...
    ]
  }
) {
  x_author @Common: { Text: x_author.name, TextArrangement: #TextOnly };
};

annotate CatalogService.Authors with @(
  UI: {
    LineItem: [
      { Value: ID },
      { Value: name },
    ]
  }
);
