openaire-library/claims/claim-utils/claimHelper.class.ts

177 lines
3.7 KiB
TypeScript

//Classes used in linking / inlinelinking when selecting an entity
import {HelperFunctions} from "../../utils/HelperFunctions.class";
export class ClaimResult {
public source: string;
public url: string;
public record: any;
public accessRights: string = "OPEN";
public embargoEndDate: string = "";
public date: string;
public authors: string[] = [];
public publisher: string;
public description: string;
DOI: string;
editors = [];
journal: string;
constructor() {
let today = new Date();
this.embargoEndDate = "" + (today.getFullYear()) + "-" + (today.getMonth() + 1) + "-" + (today.getDate());
this.authors = [];
this.accessRights = "OPEN";
this.editors = [];
}
}
export class ClaimProject {
public funderId: string;
public funderName: string;
public acronym: string;
public startDate: string;
public endDate: string;
public code: string;
public jurisdiction: string;
public fundingLevel0: string;
}
export class ClaimContext {
public community: string;
public category: string;
public concept: any;
}
export class Message {
public type: string;
public resultId: string;
public resultTitle: string;
projectId: string;
projectInfo: { title: string, startDate: string, endDate: string };
}
export class ClaimsErrorMessage {
public type: string;
inserted:number;
failed:number;
constructor(){
this.inserted = 0;
this.failed = 0;
}
}
export class ClaimEntity {
public id: string;
public type: string;
public title: string;
warningMessages: Message[];
errorMessages: Message[];
result: ClaimResult;
project: ClaimProject;
context: ClaimContext;
constructor() {
this.warningMessages = [];
this.errorMessages = [];
}
}
export class ClaimRecord2Insert {
claimedBy: string;
sourceId: string;
sourceType: string;
sourceCollectedFrom: string;
sourceAccessRights: string;
sourceEmbargoEndDate: string;
targetId: string;
targetType: string;
targetCollectedFrom: string;
targetAccessRights: string;
targetEmbargoEndDate: string;
constructor() {
}
}
export class ClaimDBRecord {
id: string;
userMail: string;
date: string;
sourceType: string;
targetType: string;
semantics: string;
approved: string;
source: ClaimDBResult | ClaimProject | ClaimContext;
target: ClaimDBResult;
indexed:boolean;
}
export class ClaimDBContext {
title: string;
openaireId: string;
}
export class ClaimDBProject {
openaireId: string;
name: string;
funderName: string;
funderId: string;
}
export class ClaimDBResult {
title: string;
authors: string[];
externalUrl: string;
openaireId: string;
doi: string;
accessRights: string;
collectedFrom: string;
resultType: string;
}
export class DirectIndexRecord {
public id: string;
record: any;
}
export class ShowOptions {
show: string; //show values: source, result, project, context, claim
linkTo: string; // linkTo /values: result, project, context
linkToEntities: string[]; // show linkToEntities /values: result, project, context
basketShowSources: boolean;
basketShowLinksTo: boolean;
constructor() {
this.show = "source";
this.linkTo = "project";
this.linkToEntities = ["project", "context", "result"];
this.basketShowSources = true;
this.basketShowLinksTo = false;
}
showSource() {
this.show = "source";
this.basketShowLinksTo = false;
this.basketShowSources = true;
HelperFunctions.scroll();
}
showLinkTo() {
this.show = this.linkTo;
this.basketShowLinksTo = true;
this.basketShowSources = false;
HelperFunctions.scroll();
}
showBasketSources() {
if (this.show != 'source') {
this.basketShowSources = !this.basketShowSources;
this.basketShowLinksTo = !this.basketShowSources;
}
}
}