jsonld:
move files in sharedComponents/schema2jsonld/model - not used only in add Organization, use JsonldDocument as the default class and extend Dataset and Organization add jsonld in search-find, org/datasource/project landing Claims: add limit in the number of results allowed to add in the basket git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@53724 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
80e22d6849
commit
f86a8891df
|
@ -233,6 +233,15 @@ isSelected(id):boolean{
|
|||
return false;
|
||||
}
|
||||
addNewContext(community,category,concept, notify=true){
|
||||
if(this.selectedList.length > 50){
|
||||
UIkit.notification({
|
||||
message : 'Your basket exceeds the number of allowed concepts (50)',
|
||||
status : 'warning',
|
||||
timeout : 1500,
|
||||
pos : 'top-center'
|
||||
});
|
||||
return;
|
||||
}
|
||||
var context: ClaimContext= { community: community, category: category, concept: concept };
|
||||
var found:boolean = false;
|
||||
this.warningMessage = "";
|
||||
|
@ -241,9 +250,9 @@ isSelected(id):boolean{
|
|||
this.selectedList.push(context);
|
||||
if(notify){
|
||||
UIkit.notification({
|
||||
message : 'A new concept added in the basket.',
|
||||
message : 'A new concept added in your basket.',
|
||||
status : 'primary',
|
||||
timeout : 1000,
|
||||
timeout : 1500,
|
||||
pos : 'top-center'
|
||||
});
|
||||
}
|
||||
|
@ -251,9 +260,9 @@ isSelected(id):boolean{
|
|||
}else{
|
||||
if(notify){
|
||||
UIkit.notification({
|
||||
message : 'The concept is already on your basket.',
|
||||
message : 'The concept is already in your basket.',
|
||||
status : 'warning',
|
||||
timeout : 1000,
|
||||
timeout : 1500,
|
||||
pos : 'top-center'
|
||||
});
|
||||
}
|
||||
|
|
|
@ -93,6 +93,15 @@ constructor(private _service: ProjectService, private _projectService: SearchPro
|
|||
//
|
||||
// }
|
||||
select(item){
|
||||
if(this.selectedProjects.length > 50){
|
||||
UIkit.notification({
|
||||
message : 'Your basket exceeds the number of allowed projects (50)',
|
||||
status : 'warning',
|
||||
timeout : 1500,
|
||||
pos : 'top-center'
|
||||
});
|
||||
return;
|
||||
}
|
||||
this.query = "";
|
||||
// this.searchTermStream.next(this.query); //clear
|
||||
item = item.value;
|
||||
|
@ -126,7 +135,7 @@ select(item){
|
|||
let item = this.selectedProjects[_i];
|
||||
if(item.projectId == project.projectId){
|
||||
found=true;
|
||||
this.warningMessage = "Project already in selected list";
|
||||
this.warningMessage = "Project already in your basket";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -141,14 +150,14 @@ select(item){
|
|||
UIkit.notification({
|
||||
message : 'A new project added in the basket.',
|
||||
status : 'primary',
|
||||
timeout : 1000,
|
||||
timeout : 1500,
|
||||
pos : 'top-center'
|
||||
});
|
||||
}else{
|
||||
UIkit.notification({
|
||||
message : 'The project is already on your basket.',
|
||||
message : 'The project is already in your basket.',
|
||||
status : 'warning',
|
||||
timeout : 1000,
|
||||
timeout : 1500,
|
||||
pos : 'top-center'
|
||||
});
|
||||
}
|
||||
|
|
|
@ -49,14 +49,23 @@ export class ClaimResultsComponent {
|
|||
|
||||
}
|
||||
add(item){
|
||||
if(this.selectedResults.length > 150){
|
||||
UIkit.notification({
|
||||
message : 'Your basket exceeds the number of allowed results (150)',
|
||||
status : 'warning',
|
||||
timeout : 1500,
|
||||
pos : 'top-center'
|
||||
});
|
||||
return;
|
||||
}
|
||||
var found:boolean = this.isSelected( item.id);
|
||||
if (!found) {
|
||||
this.selectedResults.push(item);
|
||||
|
||||
UIkit.notification({
|
||||
message : 'A new research result added in the basket.',
|
||||
message : 'A new research result added in your basket.',
|
||||
status : 'primary',
|
||||
timeout : 1000,
|
||||
timeout : 1500,
|
||||
pos : 'top-center'
|
||||
});
|
||||
if(this.results != null){
|
||||
|
@ -64,9 +73,9 @@ export class ClaimResultsComponent {
|
|||
}
|
||||
}else{
|
||||
UIkit.notification({
|
||||
message : 'The research result is already on your basket.',
|
||||
message : 'The research result is already in your basket.',
|
||||
status : 'warning',
|
||||
timeout : 1000,
|
||||
timeout : 1500,
|
||||
pos : 'top-center'
|
||||
});
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import {ModalLoading} from '../../../utils/modal/loading.component';
|
|||
import {Dates, DOI} from '../../../utils/string-utils.class';
|
||||
import {ClaimResult} from '../../claim-utils/claimEntities.class';
|
||||
import{EnvProperties} from '../../../utils/properties/env-properties';
|
||||
declare var UIkit:any;
|
||||
|
||||
|
||||
@Component({
|
||||
|
@ -85,7 +86,8 @@ export class BulkClaimComponent {
|
|||
infoMEssage = "";
|
||||
enableUpload:boolean = true;
|
||||
@Input() localStoragePrefix:string="";
|
||||
|
||||
exceedsLimit = false;
|
||||
limit =150;
|
||||
constructor(private _searchCrossrefService: SearchCrossrefService, private _searchDataciteService: SearchDataciteService) {
|
||||
this.filesToUpload = [];
|
||||
}
|
||||
|
@ -109,6 +111,7 @@ export class BulkClaimComponent {
|
|||
this.makeFileRequest(this.properties.uploadService, [], this.filesToUpload).then((result) => {
|
||||
var rows = (result as any).split('\n'); // I have used space, you can use any thing.
|
||||
console.log("Rows:" + rows.length);
|
||||
this.exceedsLimit = false;
|
||||
var i = 0;
|
||||
var invalid_rows = 0;
|
||||
this.duplicateIds = [];
|
||||
|
@ -117,8 +120,18 @@ export class BulkClaimComponent {
|
|||
this.noValidIds = [];
|
||||
this.results.slice(0,this.results.length);
|
||||
this.notFoundIds = [];
|
||||
var limit = 100;
|
||||
for(i=0;i<((rows.length>limit)?limit:rows.length);i++){
|
||||
|
||||
if(rows.length + this.results.length > this.limit){
|
||||
this.exceedsLimit = true;
|
||||
UIkit.notification({
|
||||
message : 'Your basket exceeds the number of allowed results (150)',
|
||||
status : 'warning',
|
||||
timeout : 1500,
|
||||
pos : 'top-center'
|
||||
});
|
||||
|
||||
}
|
||||
for(i=0;i<((rows.length>this.limit-this.results.length)?(this.limit-this.results.length):rows.length);i++){
|
||||
if(rows[i] && rows[i] != null ){
|
||||
console.log("Row is:" + rows[i]);
|
||||
var values = rows[i].split(',');
|
||||
|
@ -145,7 +158,7 @@ export class BulkClaimComponent {
|
|||
}
|
||||
|
||||
}
|
||||
if(rows.length == 0 || rows.length == invalid_rows || rows.length == (invalid_rows + this.noValidIds.length)){
|
||||
if(rows.length == 0 || rows.length == invalid_rows || rows.length == (invalid_rows + this.noValidIds.length) || this.limit == this.results.length ){
|
||||
this.endOfFetching();
|
||||
}
|
||||
|
||||
|
@ -249,6 +262,11 @@ export class BulkClaimComponent {
|
|||
);
|
||||
}
|
||||
endOfFetching(){
|
||||
if(this.limit == this.results.length){
|
||||
this.enableUpload = true;
|
||||
this.loading.close();
|
||||
return;
|
||||
}
|
||||
if(this.allIds.length == this.foundIds.length+this.notFoundIds.length ){
|
||||
this.showReport = true;
|
||||
this.enableUpload = true;
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
{{dataProviderInfo.title['name']}}
|
||||
</p>
|
||||
</h3-->
|
||||
<schema2jsonld *ngIf="dataProviderInfo" [data]=dataProviderInfo [URL]="properties.baseLink+'/search/dataprovider?datasourceId='+datasourceId"
|
||||
type="datasource" [otherURL]="(dataProviderInfo.openDoarId)?(properties.openDoarURL+dataProviderInfo.openDoarId):((dataProviderInfo.r3DataId)?properties.r3DataURL+dataProviderInfo.r3DataId:nul)"></schema2jsonld>
|
||||
|
||||
<showTitle [title]="dataProviderInfo.title"></showTitle>
|
||||
<div class="uk-text-large " *ngIf="dataProviderInfo.officialName && this.dataProviderInfo.title.name != dataProviderInfo.officialName ">{{dataProviderInfo.officialName}}</div>
|
||||
|
||||
|
|
|
@ -34,13 +34,14 @@ import {OrpsServiceModule} from '../../services/orpsService.module';
|
|||
// import { DataProviderRoutingModule } from './dataProvider-routing.module';
|
||||
import {FreeGuard} from'../../login/freeGuard.guard';
|
||||
import {IsRouteEnabled} from '../../error/isRouteEnabled.guard';
|
||||
import {Schema2jsonldModule} from '../../sharedComponents/schema2jsonld/schema2jsonld.module';
|
||||
|
||||
@NgModule({
|
||||
imports:
|
||||
[CommonModule, FormsModule, RouterModule,
|
||||
TabResultModule, IFrameModule, ErrorMessagesModule, MetricsModule, LandingModule,
|
||||
DataProvidersServiceModule, DatasetsServiceModule, ProjectsServiceModule, PublicationsServiceModule,
|
||||
SoftwareServiceModule, OrpsServiceModule, PagingModule],
|
||||
SoftwareServiceModule, OrpsServiceModule, PagingModule, Schema2jsonldModule],
|
||||
declarations:
|
||||
[PublicationsTabComponent, DatasetsTabComponent, StatisticsTabComponent, ProjectsTabComponent, DatasourcesTabComponent, OrganizationsTabComponent,
|
||||
RelatedDatasourcesTabComponent, DataProviderComponent, SoftwareTabComponent, OrpsTabComponent
|
||||
|
|
|
@ -21,7 +21,7 @@ import {DatasetService} from './dataset.service';
|
|||
|
||||
import {FreeGuard} from'../../login/freeGuard.guard';
|
||||
import {IsRouteEnabled} from '../../error/isRouteEnabled.guard';
|
||||
import {Schema2jsonldModule} from '../landing-utils/schema2jsonld/schema2jsonld.module';
|
||||
import {Schema2jsonldModule} from '../../sharedComponents/schema2jsonld/schema2jsonld.module';
|
||||
|
||||
|
||||
@NgModule({
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
import {Component, ElementRef, Input} from '@angular/core';
|
||||
import { OpenAireJsonldConverterService } from './service/open-aire-jsonld-converter.service';
|
||||
import { JsonldDocumentSerializerService } from './service/jsonld-document-serializer.service';
|
||||
@Component({
|
||||
selector: 'schema2jsonld',
|
||||
template: `
|
||||
<ngx-json-ld [json]="json"></ngx-json-ld>
|
||||
`
|
||||
})
|
||||
export class Schema2jsonldComponent {
|
||||
@Input() data;
|
||||
@Input() URL;
|
||||
json;
|
||||
constructor( private documentParser: OpenAireJsonldConverterService,
|
||||
private documentSerializer: JsonldDocumentSerializerService) {
|
||||
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
const docOvject = this.documentParser.convertPublication(this.data, this.URL);
|
||||
this.json = this.documentSerializer.serialize(docOvject);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
<div *ngIf="organizationInfo != null" uk-grid class="uk-grid-large">
|
||||
<div class="uk-width-expand@m uk-width-1-1@s">
|
||||
<schema2jsonld *ngIf="organizationInfo" [data]=organizationInfo [URL]="properties.baseLink+'/search/organization?organizationId='+organizationId" type="organization"></schema2jsonld>
|
||||
|
||||
<showTitle [title]="organizationInfo.title"></showTitle>
|
||||
<div class="uk-text-large " *ngIf="organizationInfo.title.name && organizationInfo.title.name != organizationInfo.name ">{{organizationInfo.name}}</div>
|
||||
<span class="uk-label custom-label label-blue label-organization" title="Type">Organization</span>
|
||||
|
|
|
@ -23,6 +23,7 @@ import {ProjectsServiceModule} from '../../services/projectsService.module';
|
|||
import { SearchingProjectsTabModule} from '../landing-utils/searchingProjectsInTab.module';
|
||||
import {FreeGuard} from'../../login/freeGuard.guard';
|
||||
import {IsRouteEnabled} from '../../error/isRouteEnabled.guard';
|
||||
import {Schema2jsonldModule} from '../../sharedComponents/schema2jsonld/schema2jsonld.module';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
|
@ -37,7 +38,8 @@ import {IsRouteEnabled} from '../../error/isRouteEnabled.guard';
|
|||
OrganizationServiceModule,
|
||||
PublicationsServiceModule,
|
||||
// DatasetsServiceModule,
|
||||
ProjectsServiceModule
|
||||
ProjectsServiceModule,
|
||||
Schema2jsonldModule
|
||||
|
||||
],
|
||||
declarations: [
|
||||
|
|
|
@ -19,7 +19,7 @@ import {OrpService} from './orp.service';
|
|||
|
||||
import {FreeGuard} from'../../login/freeGuard.guard';
|
||||
import {IsRouteEnabled} from '../../error/isRouteEnabled.guard';
|
||||
import {Schema2jsonldModule} from '../landing-utils/schema2jsonld/schema2jsonld.module';
|
||||
import {Schema2jsonldModule} from '../../sharedComponents/schema2jsonld/schema2jsonld.module';
|
||||
|
||||
|
||||
@NgModule({
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
<div *ngIf="projectInfo != null" uk-grid class="uk-grid-large">
|
||||
<div class="uk-width-expand@m uk-width-1-1@s">
|
||||
<schema2jsonld *ngIf="projectInfo" [data]=projectInfo [URL]="properties.baseLink+'/search/project?projectId='+projectId" type="project"></schema2jsonld>
|
||||
<!--h3 *ngIf="projectInfo.acronym != undefined && projectInfo.acronym != ''">{{projectInfo.acronym}}</h3>
|
||||
<h3 *ngIf="projectInfo.acronym == undefined || projectInfo.acronym == ''">{{projectInfo.title}}</h3-->
|
||||
<h2 class="projectIcon">
|
||||
|
|
|
@ -23,13 +23,16 @@ import {TabResultModule } from '../../searchPages/searchUtils/tabResult.module';
|
|||
import { LandingModule } from '../landing-utils/landing.module';
|
||||
import {FreeGuard} from'../../login/freeGuard.guard';
|
||||
import {IsRouteEnabled} from '../../error/isRouteEnabled.guard';
|
||||
import {Schema2jsonldModule} from '../../sharedComponents/schema2jsonld/schema2jsonld.module';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule, FormsModule, RouterModule, LandingModule,
|
||||
LoadingModalModule, AlertModalModule, ErrorMessagesModule,
|
||||
TabResultModule, IFrameModule, MetricsModule, ReportsServiceModule,
|
||||
PublicationsServiceModule, DatasetsServiceModule, SoftwareServiceModule, OrpsServiceModule, ProjectServiceModule
|
||||
PublicationsServiceModule, DatasetsServiceModule, SoftwareServiceModule, OrpsServiceModule, ProjectServiceModule,
|
||||
Schema2jsonldModule
|
||||
|
||||
],
|
||||
declarations: [
|
||||
ProjectComponent
|
||||
|
|
|
@ -19,7 +19,7 @@ import {FreeGuard} from'../../login/freeGuard.guard';
|
|||
import {IsRouteEnabled} from '../../error/isRouteEnabled.guard';
|
||||
import {PublicationService} from './publication.service';
|
||||
import {PublicationComponent} from './publication.component';
|
||||
import {Schema2jsonldModule} from '../landing-utils/schema2jsonld/schema2jsonld.module';
|
||||
import {Schema2jsonldModule} from '../../sharedComponents/schema2jsonld/schema2jsonld.module';
|
||||
|
||||
|
||||
@NgModule({
|
||||
|
|
|
@ -17,7 +17,7 @@ import { PagingModule } from '../../utils/paging.module';
|
|||
import { ResultLandingModule } from '../landing-utils/resultLanding.module';
|
||||
import { LandingModule } from '../landing-utils/landing.module';
|
||||
import { FreeGuard } from'../../login/freeGuard.guard';
|
||||
import {Schema2jsonldModule} from '../landing-utils/schema2jsonld/schema2jsonld.module';
|
||||
import {Schema2jsonldModule} from '../../sharedComponents/schema2jsonld/schema2jsonld.module';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
|
|
|
@ -17,6 +17,7 @@ import {PublicationsServiceModule} from '../../services/publicationsService.modu
|
|||
import {OrganizationsServiceModule} from '../../services/organizationsService.module';
|
||||
import {BrowseEntitiesModule} from '../searchUtils/browseEntities.module';
|
||||
import {SearchFormModule} from '../searchUtils/searchForm.module';
|
||||
import {Schema2jsonldModule} from '../../sharedComponents/schema2jsonld/schema2jsonld.module';
|
||||
|
||||
import {PiwikServiceModule} from '../../utils/piwik/piwikService.module';
|
||||
|
||||
|
@ -25,7 +26,7 @@ import {PiwikServiceModule} from '../../utils/piwik/piwikService.module';
|
|||
CommonModule, FormsModule, RouterModule,
|
||||
DataProvidersServiceModule, DatasetsServiceModule, SoftwareServiceModule, OrpsServiceModule, ProjectsServiceModule,
|
||||
PublicationsServiceModule, OrganizationsServiceModule,
|
||||
BrowseEntitiesModule, SearchFormModule, SearchResultsModule, PiwikServiceModule
|
||||
BrowseEntitiesModule, SearchFormModule, SearchResultsModule, PiwikServiceModule, Schema2jsonldModule
|
||||
|
||||
],
|
||||
declarations: [
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<schema2jsonld *ngIf="name && logoURL" [URL]="properties.baseLink" [logoURL] = "properties.baseLink+logoURL" type="home" [name]=name></schema2jsonld>
|
||||
|
||||
|
||||
<div id="tm-main" class=" uk-section uk-padding-remove-top tm-middle" >
|
||||
|
|
|
@ -96,6 +96,8 @@ export class SearchComponent {
|
|||
showOrganizations:boolean= false;
|
||||
advancedSearchLink:string ="/search/advanced/publications";
|
||||
properties: EnvProperties;
|
||||
@Input() logoURL;
|
||||
@Input() name;
|
||||
|
||||
public subPub;public subData; public subSoftware; public subOrps; public subProjects;public subOrg; public subDataPr;
|
||||
constructor ( private route: ActivatedRoute,
|
||||
|
|
|
@ -4,6 +4,10 @@ export class JsonldDocument {
|
|||
identifier: Identifier[];
|
||||
url: String[];
|
||||
sameAs: String[];
|
||||
|
||||
}
|
||||
|
||||
export class Dataset extends JsonldDocument {
|
||||
creator: Person[];
|
||||
dateCreated: String[];
|
||||
dateModified: String[];
|
||||
|
@ -32,3 +36,10 @@ export interface License {
|
|||
title: string[];
|
||||
identifier: Identifier[];
|
||||
}
|
||||
export class Organization extends JsonldDocument {
|
||||
alumni:Person;
|
||||
areaServed:string; //The geographic area where a service or offered item is provided. Supersedes serviceArea.
|
||||
funder:Organization;
|
||||
legalName:string;
|
||||
logo:string;
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
import {Component, ElementRef, Input} from '@angular/core';
|
||||
import { OpenAireJsonldConverterService } from './service/open-aire-jsonld-converter.service';
|
||||
import { JsonldDocumentSerializerService } from './service/jsonld-document-serializer.service';
|
||||
@Component({
|
||||
selector: 'schema2jsonld',
|
||||
template: `
|
||||
<ngx-json-ld [json]="json"></ngx-json-ld>
|
||||
|
||||
`
|
||||
})
|
||||
export class Schema2jsonldComponent {
|
||||
@Input() data;
|
||||
@Input() URL;
|
||||
@Input() logoURL;
|
||||
@Input() otherURL;
|
||||
@Input() name;
|
||||
@Input() type="result";
|
||||
|
||||
json;
|
||||
constructor( private documentParser: OpenAireJsonldConverterService,
|
||||
private documentSerializer: JsonldDocumentSerializerService) {
|
||||
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
var docOvject;
|
||||
if(this.type == 'project'){
|
||||
docOvject = this.documentParser.convertProject(this.data, this.URL, this.otherURL);
|
||||
this.json = this.documentSerializer.serializeOrganization(docOvject);
|
||||
}else if(this.type == 'organization'){
|
||||
docOvject = this.documentParser.convertOrganization(this.data, this.URL);
|
||||
this.json = this.documentSerializer.serializeOrganization(docOvject);
|
||||
}else if(this.type == 'datasource'){
|
||||
docOvject = this.documentParser.convertDatasource(this.data, this.URL, this.otherURL);
|
||||
this.json = this.documentSerializer.serializeOrganization(docOvject);
|
||||
}else if(this.type == 'home'){
|
||||
this.json = this.documentParser.createHome(this.name, this.URL, this.logoURL);
|
||||
}else{
|
||||
docOvject = this.documentParser.convertResult(this.data, this.URL);
|
||||
this.json = this.documentSerializer.serializeDataset(docOvject);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,53 +1,40 @@
|
|||
import { Injectable } from "@angular/core";
|
||||
import { JsonldDocument, Identifier, Person, License, Citation } from "../model/jsonld-document";
|
||||
import { JsonldDocument, Identifier, Person, License, Citation, Dataset, Organization } from "../model/jsonld-document";
|
||||
import * as _ from "lodash";
|
||||
|
||||
@Injectable()
|
||||
export class JsonldDocumentSerializerService {
|
||||
constructor() { }
|
||||
|
||||
serialize(doc: JsonldDocument): any {
|
||||
serializeOrganization(doc: Organization): any {
|
||||
const buffer = {};
|
||||
buffer["@type"] = "Organization";
|
||||
this.serializeDocument(doc, buffer);
|
||||
if(doc.areaServed){
|
||||
buffer["areaServed"] = doc.areaServed;
|
||||
}
|
||||
if(doc.legalName){
|
||||
buffer["legalName"] = doc.legalName;
|
||||
}
|
||||
if(doc.funder ){
|
||||
buffer["funder"] = this.serializeOrganization(doc.funder );
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
serializeDocument(doc:JsonldDocument, buffer):any{
|
||||
buffer["@context"] = "http://schema.org";
|
||||
this.serializeName(doc, buffer);
|
||||
this.serializeDescription(doc, buffer);
|
||||
this.serializeIdentifier(doc, buffer);
|
||||
this.serializeURL(doc, buffer);
|
||||
this.serializeSameAs(doc, buffer);
|
||||
}
|
||||
serializeDataset(doc: Dataset): any {
|
||||
var buffer = {};
|
||||
buffer["@context"] = "http://schema.org";
|
||||
buffer["@type"] = "Dataset";
|
||||
if (doc.title && doc.title.length == 1) {
|
||||
buffer["name"] = doc.title[0];
|
||||
}
|
||||
else if (doc.title && doc.title.length > 1) {
|
||||
buffer["name"] = doc.title;
|
||||
}
|
||||
|
||||
if (doc.description && doc.description.length == 1) {
|
||||
buffer["description"] = doc.description[0];
|
||||
}
|
||||
else if (doc.description && doc.description.length > 1) {
|
||||
buffer["description"] = doc.description;
|
||||
}
|
||||
|
||||
if (doc.identifier && doc.identifier.length == 1) {
|
||||
buffer["identifier"] = this.buildIdentifier(doc.identifier[0]);
|
||||
}
|
||||
else if (doc.identifier && doc.identifier.length > 1) {
|
||||
const array = new Array<any>();
|
||||
for (var i = 0; i < doc.identifier.length; i += 1) {
|
||||
array.push(this.buildIdentifier(doc.identifier[i]));
|
||||
}
|
||||
buffer["identifier"] = array;
|
||||
}
|
||||
|
||||
if (doc.url && doc.url.length == 1) {
|
||||
buffer["url"] = doc.url[0];
|
||||
}
|
||||
else if (doc.url && doc.url.length > 1) {
|
||||
buffer["url"] = doc.url;
|
||||
}
|
||||
|
||||
if (doc.sameAs && doc.sameAs.length == 1) {
|
||||
buffer["sameAs"] = doc.sameAs[0];
|
||||
}
|
||||
else if (doc.sameAs && doc.sameAs.length > 1) {
|
||||
buffer["sameAs"] = doc.sameAs;
|
||||
}
|
||||
this.serializeDocument(doc, buffer);
|
||||
|
||||
if (doc.creator && doc.creator.length == 1) {
|
||||
buffer["creator"] = this.buildCreator(doc.creator[0]);
|
||||
|
@ -108,6 +95,52 @@ export class JsonldDocumentSerializerService {
|
|||
// }, 4);
|
||||
}
|
||||
|
||||
serializeName(doc, buffer){
|
||||
if (doc.title && doc.title.length == 1) {
|
||||
buffer["name"] = doc.title[0];
|
||||
}
|
||||
else if (doc.title && doc.title.length > 1) {
|
||||
buffer["name"] = doc.title;
|
||||
}
|
||||
}
|
||||
|
||||
serializeDescription(doc, buffer){
|
||||
if (doc.description && doc.description.length == 1) {
|
||||
buffer["description"] = doc.description[0];
|
||||
}
|
||||
else if (doc.description && doc.description.length > 1) {
|
||||
buffer["description"] = doc.description;
|
||||
}
|
||||
}
|
||||
serializeIdentifier(doc, buffer){
|
||||
if (doc.identifier && doc.identifier.length == 1) {
|
||||
buffer["identifier"] = this.buildIdentifier(doc.identifier[0]);
|
||||
}
|
||||
else if (doc.identifier && doc.identifier.length > 1) {
|
||||
const array = new Array<any>();
|
||||
for (var i = 0; i < doc.identifier.length; i += 1) {
|
||||
array.push(this.buildIdentifier(doc.identifier[i]));
|
||||
}
|
||||
buffer["identifier"] = array;
|
||||
}
|
||||
}
|
||||
serializeURL(doc, buffer){
|
||||
if (doc.url && doc.url.length == 1) {
|
||||
buffer["URL"] = doc.url[0];
|
||||
}
|
||||
else if (doc.url && doc.url.length > 1) {
|
||||
buffer["URL"] = doc.url;
|
||||
}
|
||||
}
|
||||
serializeSameAs(doc, buffer){
|
||||
if (doc.sameAs && doc.sameAs.length == 1) {
|
||||
buffer["sameAs"] = doc.sameAs[0];
|
||||
}
|
||||
else if (doc.sameAs && doc.sameAs.length > 1) {
|
||||
buffer["sameAs"] = doc.sameAs;
|
||||
}
|
||||
}
|
||||
|
||||
buildIdentifier(item: Identifier): any {
|
||||
return {
|
||||
"@type": "PropertyValue",
|
|
@ -1,13 +1,36 @@
|
|||
import { Injectable } from "@angular/core";
|
||||
import { JsonldDocument, Identifier, Person, License, Citation } from "../model/jsonld-document";
|
||||
import { JsonldDocument, Identifier, Person, License, Citation, Dataset, Organization } from "../model/jsonld-document";
|
||||
import * as _ from "lodash";
|
||||
|
||||
@Injectable()
|
||||
export class OpenAireJsonldConverterService {
|
||||
constructor() { }
|
||||
|
||||
convertPublication(result: any, URL): JsonldDocument {
|
||||
const doc = new JsonldDocument();
|
||||
createHome(name, URL, logoURL): any {
|
||||
const buffer = {};
|
||||
buffer["@context"] = "http://schema.org";
|
||||
buffer["@type"] = "Organization";
|
||||
buffer["name"] = name;
|
||||
buffer["url"] = URL;
|
||||
buffer["logo"] = logoURL;
|
||||
const action ={};
|
||||
action["@type"]= "SearchAction";
|
||||
action["target"]= URL+"/search/find/?keyword={search_term_string}";
|
||||
action["query-input"]= "required name=search_term_string";
|
||||
|
||||
buffer["potentialAction"] = action;
|
||||
const sameAs =["https://www.openaire.eu",
|
||||
"https://www.facebook.com/groups/openaire/",
|
||||
"https://www.twitter.com/OpenAIRE_eu",
|
||||
"https://www.linkedin.com/groups/OpenAIRE-3893548",
|
||||
"https://www.slideshare.net/OpenAIRE_eu",
|
||||
"https://www.youtube.com/channel/UChFYqizc-S6asNjQSoWuwjw"];
|
||||
|
||||
buffer["sameAs"] = sameAs;
|
||||
return buffer;
|
||||
}
|
||||
convertResult(result: any, URL): Dataset {
|
||||
const doc = new Dataset();
|
||||
|
||||
doc.title = this.getTitle(result);
|
||||
doc.description = this.getDescription(result);
|
||||
|
@ -19,7 +42,60 @@ export class OpenAireJsonldConverterService {
|
|||
doc.citation = this.getCitation(result);
|
||||
doc.license = this.getLicense(result);
|
||||
doc.keyword = this.getKeyword(result);
|
||||
return doc;
|
||||
}
|
||||
|
||||
convertProject(project: any, URL, otherUrl): Organization {
|
||||
const doc = new Organization();
|
||||
|
||||
doc.title = (project.name)?project.title:project.acronym;
|
||||
doc.identifier = new Array<Identifier>();
|
||||
doc.identifier.push({id:project.contractNum, schema: "grantid"});
|
||||
var funder = new Organization();
|
||||
funder.title = project.funder;
|
||||
doc.funder = funder;
|
||||
doc.url = URL;
|
||||
doc.sameAs =[project.url]
|
||||
return doc;
|
||||
}
|
||||
|
||||
convertOrganization(organization: any, URL): Organization {
|
||||
const doc = new Organization();
|
||||
|
||||
doc.title = organization.title.name ;
|
||||
doc.legalName = organization.name;
|
||||
doc.areaServed = organization.country;
|
||||
doc.url = URL;
|
||||
|
||||
return doc;
|
||||
}
|
||||
|
||||
convertDatasource(datasource: any, URL, otherUrl): Organization {
|
||||
const doc = new Organization();
|
||||
|
||||
doc.title = datasource.title.name
|
||||
doc.identifier = datasource.contractNum;
|
||||
doc.legalName = datasource.officialName;
|
||||
// doc.areaServed = datasource.country;
|
||||
console.log("HERE")
|
||||
console.log(datasource.countries)
|
||||
if(datasource.countries && datasource.countries.length > 0){
|
||||
doc.areaServed = datasource.countries[0];
|
||||
}
|
||||
doc.url = URL;
|
||||
if(datasource.oaiPmhURL || otherUrl || datasource.title.url){
|
||||
doc.sameAs = [];
|
||||
if(otherUrl){
|
||||
doc.sameAs.push(otherUrl);
|
||||
}
|
||||
if(datasource.oaiPmhURL){
|
||||
doc.sameAs.push(datasource.oaiPmhURL);
|
||||
|
||||
}
|
||||
if(datasource.title.url){
|
||||
doc.sameAs.push(datasource.title.url);
|
||||
}
|
||||
}
|
||||
return doc;
|
||||
}
|
||||
|
Loading…
Reference in New Issue