Skip to content
Snippets Groups Projects
collection.model.ts 3.64 KiB
Newer Older
import { autoserialize, deserialize, inheritSerialization } from 'cerialize';
import { link, typedObject } from '../cache/builders/build-decorators';
import { PaginatedList } from '../data/paginated-list';
import { RemoteData } from '../data/remote-data';
William Welling's avatar
William Welling committed
import { Bitstream } from './bitstream.model';
import { BITSTREAM } from './bitstream.resource-type';
import { COLLECTION } from './collection.resource-type';
import { DSpaceObject } from './dspace-object.model';
Art Lowel's avatar
Art Lowel committed
import { HALLink } from './hal-link.model';
Giuseppe's avatar
Giuseppe committed
import { License } from './license.model';
import { LICENSE } from './license.resource-type';
Giuseppe's avatar
Giuseppe committed
import { ResourcePolicy } from './resource-policy.model';
import { RESOURCE_POLICY } from './resource-policy.resource-type';
lotte's avatar
lotte committed
import { COMMUNITY } from './community.resource-type';
import { Community } from './community.model';
import { ChildHALResource } from './child-hal-resource.model';
import { GROUP } from '../eperson/models/group.resource-type';
import { Group } from '../eperson/models/group.model';
@inheritSerialization(DSpaceObject)
lotte's avatar
lotte committed
export class Collection extends DSpaceObject implements ChildHALResource {

  /**
   * A string representing the unique handle of this Collection
   */
  @autoserialize
   * The {@link HALLink}s for this Collection
   */
  @deserialize
  _links: {
    license: HALLink;
    harvester: HALLink;
    mappedItems: HALLink;
    itemtemplate: HALLink;
    defaultAccessConditions: HALLink;
    logo: HALLink;
lotte's avatar
lotte committed
    parentCommunity: HALLink;
    self: HALLink;
  };

  /**
   * The license for this Collection
   * Will be undefined unless the license {@link HALLink} has been resolved.
   */
  @link(LICENSE)
  license?: Observable<RemoteData<License>>;

  /**
   * The logo for this Collection
   * Will be undefined unless the logo {@link HALLink} has been resolved.
   */
  @link(BITSTREAM)
  logo?: Observable<RemoteData<Bitstream>>;

  /**
   * The default access conditions for this Collection
   * Will be undefined unless the defaultAccessConditions {@link HALLink} has been resolved.
   */
  @link(RESOURCE_POLICY, true)
  defaultAccessConditions?: Observable<RemoteData<PaginatedList<ResourcePolicy>>>;

lotte's avatar
lotte committed
  /**
   * The Community that is a direct parent of this Collection
   * Will be undefined unless the parent community HALLink has been resolved.
   */
  @link(COMMUNITY, false)
  parentCommunity?: Observable<RemoteData<Community>>;

  /**
   * The administrators group of this community.
   */
  @link(GROUP)
  adminGroup?: Observable<RemoteData<Group>>;

  /**
   * The introductory text of this Collection
   * Corresponds to the metadata field dc.description
   */
  get introductoryText(): string {
    return this.firstMetadataValue('dc.description');
  }

  /**
   * The short description: HTML
   * Corresponds to the metadata field dc.description.abstract
   */
  get shortDescription(): string {
    return this.firstMetadataValue('dc.description.abstract');
  }

  /**
   * The copyright text of this Collection
   * Corresponds to the metadata field dc.rights
   */
  get copyrightText(): string {
    return this.firstMetadataValue('dc.rights');
  }

  /**
   * The license of this Collection
   * Corresponds to the metadata field dc.rights.license
   */
Giuseppe's avatar
Giuseppe committed
  get dcLicense(): string {
    return this.firstMetadataValue('dc.rights.license');
  }

  /**
   * The sidebar text of this Collection
   * Corresponds to the metadata field dc.description.tableofcontents
   */
  get sidebarText(): string {
    return this.firstMetadataValue('dc.description.tableofcontents');
lotte's avatar
lotte committed

  getParentLinkKey(): keyof this['_links'] {
    return 'parentCommunity';
  }