import {properties} from "../../environments/environment";

interface Links {
  searchLinkToResult;
  searchLinkToPublication;
  searchLinkToProject;
  searchLinkToDataProvider;
  searchLinkToDataset;
  searchLinkToSoftwareLanding;
  searchLinkToOrp;
  searchLinkToOrganization;
  searchLinkToResults,
  searchLinkToProjects,
  searchLinkToDataProviders,
  searchLinkToOrganizations,
  searchLinkToAdvancedResults,
  searchLinkToAdvancedProjects,
  searchLinkToAdvancedDataProviders,
  searchLinkToAdvancedOrganizations,
}

export class LinksResolver {
  
  private static default: Links = {
    searchLinkToResult: properties.searchLinkToResult,
    searchLinkToPublication: properties.searchLinkToPublication,
    searchLinkToProject: properties.searchLinkToProject,
    searchLinkToDataProvider: properties.searchLinkToDataProvider,
    searchLinkToDataset: properties.searchLinkToDataset,
    searchLinkToSoftwareLanding: properties.searchLinkToSoftwareLanding,
    searchLinkToOrp: properties.searchLinkToOrp,
    searchLinkToOrganization: properties.searchLinkToOrganization,
    searchLinkToResults: properties.searchLinkToResults,
    searchLinkToDataProviders: properties.searchLinkToDataProviders,
    searchLinkToProjects: properties.searchLinkToProjects,
    searchLinkToOrganizations: properties.searchLinkToOrganizations,
    searchLinkToAdvancedResults: properties.searchLinkToAdvancedResults,
    searchLinkToAdvancedProjects: properties.searchLinkToAdvancedProjects,
    searchLinkToAdvancedDataProviders: properties.searchLinkToAdvancedDataProviders,
    searchLinkToAdvancedOrganizations: properties.searchLinkToAdvancedOrganizations,
  };
  
  public static setProperties( alias: string) {
    Object.keys(this.default).forEach(field => {
      properties[field] = "/" + alias + (<string>this.default[field]);
    });
  }
  
  public static resetProperties() {
    Object.keys(this.default).forEach(field => {
      properties[field] = this.default[field];
    });
  }
}
