in services use function console.log instead of console.error | re-enable cache for project & organization service | in services add result in cache before custom parsing

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@44907 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2016-12-12 15:45:58 +00:00
parent 358017a7da
commit 0272dc0250
61 changed files with 296 additions and 263 deletions

View File

@ -121,7 +121,7 @@ getCommunities () {
data => { data => {
this.communities = data.communities; this.communities = data.communities;
}, },
err => console.error(err) err => console.log(err)
); );
} }
getCategories () { getCategories () {
@ -138,7 +138,7 @@ getCommunities () {
} }
}, },
err => console.error(err) err => console.log(err)
); );
} }
} }
@ -154,7 +154,7 @@ getCommunities () {
// this.filter(event); // this.filter(event);
} }
}, },
err => console.error(err) err => console.log(err)
); );
}else{ }else{
this.concepts=[]; this.concepts=[];

View File

@ -142,7 +142,7 @@ export class ClaimDatasetComponent {
}, },
err => { err => {
this.openaireStatus = this.errorCodes.ERROR; this.openaireStatus = this.errorCodes.ERROR;
console.error(err.status); console.log(err.status);
} }
); );
}else{ }else{
@ -160,7 +160,7 @@ export class ClaimDatasetComponent {
}, },
err => { err => {
this.openaireStatus = this.errorCodes.ERROR; this.openaireStatus = this.errorCodes.ERROR;
console.error(err.status); console.log(err.status);
} }
); );
} }
@ -180,7 +180,7 @@ export class ClaimDatasetComponent {
}, },
err => { err => {
this.dataciteStatus = this.errorCodes.ERROR; this.dataciteStatus = this.errorCodes.ERROR;
console.error(err); console.log(err);
} }
); );

View File

@ -126,7 +126,7 @@ select(item){
// project.startDate = data.startDate; // project.startDate = data.startDate;
// project.endDate = data.endDate; // project.endDate = data.endDate;
// }, // },
// err => console.error(err) // err => console.log(err)
// ); // );
var index:number =this.selectedProjects.indexOf(project); var index:number =this.selectedProjects.indexOf(project);
var found:boolean = false; var found:boolean = false;
@ -172,7 +172,7 @@ getFunders () {
data => { data => {
this.funders = data[1]; this.funders = data[1];
}, },
err => console.error(err) err => console.log(err)
); );
} }

View File

@ -107,7 +107,7 @@ private getCrossrefResults (term: string, size : number, page : number) {
} }
}, },
err =>{ err =>{
console.error(err.status); console.log(err.status);
this.crossrefStatus = this.errorCodes.ERROR; this.crossrefStatus = this.errorCodes.ERROR;
} }
@ -118,7 +118,7 @@ private getCrossrefResults (term: string, size : number, page : number) {
} }
}, },
err => { err => {
//console.error(err); //console.log(err);
this._searchCrossrefService.searchCrossrefResults(term, size, page).subscribe( this._searchCrossrefService.searchCrossrefResults(term, size, page).subscribe(
data => { data => {
this.crossrefResults = data.items; this.crossrefResults = data.items;
@ -128,7 +128,7 @@ private getCrossrefResults (term: string, size : number, page : number) {
}, },
err => { err => {
console.error(err.status); console.log(err.status);
this.crossrefStatus = this.errorCodes.ERROR; this.crossrefStatus = this.errorCodes.ERROR;
} }
@ -153,7 +153,7 @@ private getCrossrefResults (term: string, size : number, page : number) {
}, },
err => { err => {
console.error(err.status); console.log(err.status);
this.crossrefStatus = this.errorCodes.ERROR; this.crossrefStatus = this.errorCodes.ERROR;
} }
); );
@ -179,7 +179,7 @@ private getCrossrefResults (term: string, size : number, page : number) {
}, },
err => { err => {
this.openaireStatus = this.errorCodes.ERROR; this.openaireStatus = this.errorCodes.ERROR;
console.error(err.status); console.log(err.status);
} }
); );
}else{ }else{
@ -200,7 +200,7 @@ private getCrossrefResults (term: string, size : number, page : number) {
}, },
err => { err => {
this.openaireStatus = this.errorCodes.ERROR; this.openaireStatus = this.errorCodes.ERROR;
console.error(err.status); console.log(err.status);
} }
); );
} }
@ -260,7 +260,7 @@ private getCrossrefResults (term: string, size : number, page : number) {
this.getOrcidAuthors(term); this.getOrcidAuthors(term);
} else { } else {
this.orcidStatus = this.errorCodes.ERROR; this.orcidStatus = this.errorCodes.ERROR;
console.error(err.status); console.log(err.status);
} }
} }
@ -281,7 +281,7 @@ private getCrossrefResults (term: string, size : number, page : number) {
}, },
err => { err => {
this.orcidStatus = this.errorCodes.ERROR; this.orcidStatus = this.errorCodes.ERROR;
console.error(err.status); console.log(err.status);
} }
); );
} }
@ -320,7 +320,7 @@ private getCrossrefResults (term: string, size : number, page : number) {
this.authorId = id; this.authorId = id;
}, },
err => { err => {
console.error(err.status); console.log(err.status);
this.orcidStatus = this.errorCodes.ERROR; this.orcidStatus = this.errorCodes.ERROR;
} }
); );

View File

@ -133,7 +133,7 @@ export class ClaimsComponent {
this.resultsNum= data.total; this.resultsNum= data.total;
}, },
err => { err => {
console.error(err); console.log(err);
this.showErrorMessage = true; this.showErrorMessage = true;
} }
); );
@ -144,7 +144,7 @@ export class ClaimsComponent {
this.resultsNum= data.total; this.resultsNum= data.total;
}, },
err => { err => {
console.error(err); console.log(err);
this.showErrorMessage = true; this.showErrorMessage = true;
} }
); );
@ -155,7 +155,7 @@ export class ClaimsComponent {
this.resultsNum= data.total; this.resultsNum= data.total;
}, },
err => { err => {
console.error(err); console.log(err);
this.showErrorMessage = true; this.showErrorMessage = true;
} }
); );
@ -167,7 +167,7 @@ export class ClaimsComponent {
this.resultsNum= data.total;//data.length; //TODO get the total results num this.resultsNum= data.total;//data.length; //TODO get the total results num
}, },
err => { err => {
console.error(err); console.log(err);
this.showErrorMessage = true; this.showErrorMessage = true;
} }
); );
@ -179,7 +179,7 @@ export class ClaimsComponent {
this.resultsNum= data.total;//data.length; //TODO get the total results num this.resultsNum= data.total;//data.length; //TODO get the total results num
}, },
err => { err => {
console.error(err); console.log(err);
this.showErrorMessage = true; this.showErrorMessage = true;
} }
); );

View File

@ -119,7 +119,7 @@ export class BulkClaimComponent {
}, (error) => { }, (error) => {
this.enableUpload = true; this.enableUpload = true;
console.error(error); console.log(error);
// this.loading.close(); // this.loading.close();
this.errorMessage = "An error occured while uploading..."; this.errorMessage = "An error occured while uploading...";
}); });
@ -188,7 +188,7 @@ export class BulkClaimComponent {
this.endOfFetching(); this.endOfFetching();
}, },
err => { err => {
console.error(err); console.log(err);
this.notFound++; this.notFound++;
this.notFoundIds.push(id); this.notFoundIds.push(id);
this.endOfFetching(); this.endOfFetching();

View File

@ -125,7 +125,7 @@ private insert(){
this.afterclaimsInsertion(data.insertedIds,data.errorInClaims); this.afterclaimsInsertion(data.insertedIds,data.errorInClaims);
}, },
err => { err => {
console.error(err); console.log(err);
this.errorsInClaimsInsertion(err.insertedIds,err.errorInClaims); this.errorsInClaimsInsertion(err.insertedIds,err.errorInClaims);
} }
); );

View File

@ -144,7 +144,7 @@ export class DepositResultComponent {
}); });
}, },
err => { err => {
//console.error(err) //console.log(err)
if(err.status == '404') { if(err.status == '404') {
this.status = this.errorCodes.NONE; this.status = this.errorCodes.NONE;

View File

@ -80,7 +80,7 @@ export class DataProviderComponent {
console.info(this.dataProviderInfo.resultsBy); console.info(this.dataProviderInfo.resultsBy);
}, },
err => { err => {
console.error(err) console.log(err)
console.info("error"); console.info("error");
this.errorMessage = 'No dataProvider found'; this.errorMessage = 'No dataProvider found';
} }

View File

@ -220,7 +220,7 @@ export class TabsComponent {
this.metrics = data; this.metrics = data;
}, },
err => { err => {
console.error(err); console.log(err);
console.info("error"); console.info("error");
} }
); );

View File

@ -65,7 +65,7 @@ export class DatasetComponent {
}, },
err => { err => {
console.error(err) console.log(err)
console.info("error"); console.info("error");
this.errorMessage = 'No dataset found'; this.errorMessage = 'No dataset found';
@ -81,7 +81,7 @@ export class DatasetComponent {
this.metrics = data; this.metrics = data;
}, },
err => { err => {
console.error(err); console.log(err);
console.info("error"); console.info("error");
this.errorMessage = 'No dataset metrics found'; this.errorMessage = 'No dataset metrics found';

View File

@ -67,7 +67,7 @@ export class OrganizationComponent {
console.info("this.searchDataprovidersComponent.searchUtils.totalResults = "+this.searchDataprovidersComponent.searchUtils.totalResults); console.info("this.searchDataprovidersComponent.searchUtils.totalResults = "+this.searchDataprovidersComponent.searchUtils.totalResults);
}, },
err => { err => {
console.error(err); console.log(err);
} }
); );
}) })
@ -104,7 +104,7 @@ export class OrganizationComponent {
this.projectsNum = projectsNum; this.projectsNum = projectsNum;
}, },
err => { err => {
console.error(err) console.log(err)
this.errorMessage = 'No organization found'; this.errorMessage = 'No organization found';
} }
@ -118,7 +118,7 @@ export class OrganizationComponent {
this.metrics = data; this.metrics = data;
}, },
err => { err => {
console.error(err); console.log(err);
console.info("error"); console.info("error");
this.errorMessage = 'No organization metrics found'; this.errorMessage = 'No organization metrics found';

View File

@ -66,7 +66,7 @@ export class PersonComponent {
this.searchDatasetsComponent.searchUtils.totalResults = data; this.searchDatasetsComponent.searchUtils.totalResults = data;
}, },
err => { err => {
console.error(err); console.log(err);
} }
); );
}) })
@ -102,7 +102,7 @@ export class PersonComponent {
this.personInfo = data; this.personInfo = data;
}, },
err => { err => {
console.error(err) console.log(err)
console.info("error"); console.info("error");
this.errorMessage = 'No person found'; this.errorMessage = 'No person found';

View File

@ -56,7 +56,7 @@
<div class="text-right"> <div class="text-right">
<button (click)=" toggleClaimResult()" class = "btn btn-primary btn-xs" >Add Research Results</button> <button (click)=" toggleClaimResult()" class = "btn btn-primary btn-xs" >Add Research Results</button>
</div> </div>
<inline-claim-result inlineType ="project" [inlineEntity]="project" (datasetAdded)="resultsAdded($event,false)" (publicationAdded)="resultsAdded($event,true)" ></inline-claim-result> <inline-claim-result inlineType ="'project'" [inlineEntity]=project (datasetAdded)="resultsAdded($event,false)" (publicationAdded)="resultsAdded($event,true)" ></inline-claim-result>
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
<li class="active"> <li class="active">

View File

@ -67,7 +67,7 @@ export class ProjectComponent{
this.searchDatasetsComponent.searchUtils.totalResults = data; this.searchDatasetsComponent.searchUtils.totalResults = data;
}, },
err => { err => {
console.error(err); console.log(err);
}); });
}else{ }else{
this.warningMessage="No valid project id"; this.warningMessage="No valid project id";
@ -115,9 +115,11 @@ export class ProjectComponent{
data => { data => {
this.projectInfo = data; this.projectInfo = data;
this.project= { funderId: "", funderName: this.projectInfo.funder, projectId: this.projectId, projectName: this.projectInfo.title, projectAcronym: this.projectInfo.acronym, startDate: this.projectInfo.startDate, endDate: this.projectInfo.endDate }; this.project= { funderId: "", funderName: this.projectInfo.funder, projectId: this.projectId, projectName: this.projectInfo.title, projectAcronym: this.projectInfo.acronym, startDate: this.projectInfo.startDate, endDate: this.projectInfo.endDate };
console.log(this.project);
}, },
err => { err => {
console.error(err); console.log(err);
this.errorMessage = 'No project found'; this.errorMessage = 'No project found';
} }
); );
@ -130,7 +132,7 @@ export class ProjectComponent{
this.metrics = data; this.metrics = data;
}, },
err => { err => {
console.error(err); console.log(err);
console.info("error"); console.info("error");
this.errorMessage = 'No project metrics found'; this.errorMessage = 'No project metrics found';

View File

@ -110,7 +110,7 @@ ngAfterViewChecked() {
// this.result.push(result_); // this.result.push(result_);
}, },
err => { err => {
console.error(err); console.log(err);
console.info("error"); console.info("error");
this.errorMessage = 'No publication found'; this.errorMessage = 'No publication found';
@ -126,7 +126,7 @@ ngAfterViewChecked() {
this.metrics = data; this.metrics = data;
}, },
err => { err => {
console.error(err); console.log(err);
console.info("error"); console.info("error");
this.errorMessage = 'No publication metrics found'; this.errorMessage = 'No publication metrics found';

View File

@ -92,7 +92,7 @@ export class LoginComponent {
console.info(data); console.info(data);
}, },
err => { err => {
console.error(err); console.log(err);
} }
); );

View File

@ -93,7 +93,7 @@
// this.page=page; // this.page=page;
// this.resultsNum = data['total-results']; // this.resultsNum = data['total-results'];
// }, // },
// err => console.error(err) // err => console.log(err)
// ); // );
// } // }
// searchOpenaire (term2: string) { // searchOpenaire (term2: string) {

View File

@ -79,7 +79,7 @@ export class AdvancedSearchDataProvidersComponent {
} }
}, },
err => { err => {
console.error(err); console.log(err);
console.info("error"); console.info("error");
//TODO check erros (service not available, bad request) //TODO check erros (service not available, bad request)
// if( ){ // if( ){

View File

@ -84,7 +84,7 @@ export class AdvancedSearchDatasetsComponent {
} }
}, },
err => { err => {
console.error(err); console.log(err);
console.info("error"); console.info("error");
//TODO check erros (service not available, bad request) //TODO check erros (service not available, bad request)
// if( ){ // if( ){

View File

@ -81,7 +81,7 @@ export class AdvancedSearchOrganizationsComponent {
} }
}, },
err => { err => {
console.error(err); console.log(err);
console.info("error"); console.info("error");
//TODO check erros (service not available, bad request) //TODO check erros (service not available, bad request)
// if( ){ // if( ){

View File

@ -83,7 +83,7 @@ export class AdvancedSearchPeopleComponent {
} }
}, },
err => { err => {
console.error(err); console.log(err);
console.info("error"); console.info("error");
//TODO check erros (service not available, bad request) //TODO check erros (service not available, bad request)
// if( ){ // if( ){

View File

@ -82,7 +82,7 @@ export class AdvancedSearchProjectsComponent {
} }
}, },
err => { err => {
console.error(err); console.log(err);
console.info("error"); console.info("error");
//TODO check erros (service not available, bad request) //TODO check erros (service not available, bad request)
// if( ){ // if( ){

View File

@ -83,7 +83,7 @@ export class AdvancedSearchPublicationsComponent {
} }
}, },
err => { err => {
console.error(err); console.log(err);
console.info("error"); console.info("error");
//TODO check erros (service not available, bad request) //TODO check erros (service not available, bad request)
// if( ){ // if( ){

View File

@ -95,7 +95,7 @@ export class SearchCompatibleDataprovidersComponent {
} }
}, },
err => { err => {
console.error(err); console.log(err);
//TODO check erros (service not available, bad request) //TODO check erros (service not available, bad request)
// if( ){ // if( ){
// this.searchUtils.status = ErrorCodes.ERROR; // this.searchUtils.status = ErrorCodes.ERROR;
@ -162,7 +162,7 @@ export class SearchCompatibleDataprovidersComponent {
this.searchUtils.status = errorCodes.DONE; this.searchUtils.status = errorCodes.DONE;
}, },
err => { err => {
console.error(err); console.log(err);
//TODO check erros (service not available, bad request) //TODO check erros (service not available, bad request)
// if( ){ // if( ){
// this.searchUtils.status = ErrorCodes.ERROR; // this.searchUtils.status = ErrorCodes.ERROR;

View File

@ -95,7 +95,7 @@ export class SearchEntityRegistriesComponent {
} }
}, },
err => { err => {
console.error(err); console.log(err);
//TODO check erros (service not available, bad request) //TODO check erros (service not available, bad request)
// if( ){ // if( ){
// this.searchUtils.status = ErrorCodes.ERROR; // this.searchUtils.status = ErrorCodes.ERROR;
@ -160,7 +160,7 @@ export class SearchEntityRegistriesComponent {
this.searchUtils.status = errorCodes.DONE; this.searchUtils.status = errorCodes.DONE;
}, },
err => { err => {
console.error(err); console.log(err);
//TODO check erros (service not available, bad request) //TODO check erros (service not available, bad request)
// if( ){ // if( ){
// this.searchUtils.status = ErrorCodes.ERROR; // this.searchUtils.status = ErrorCodes.ERROR;

View File

@ -283,7 +283,7 @@ public subPub;public subData;public subProjects;public subOrg;public subPeople;
this.searchPublicationsComponent.searchUtils.totalResults = data; this.searchPublicationsComponent.searchUtils.totalResults = data;
}, },
err => { err => {
console.error(err); console.log(err);
} }
); );
}) })
@ -294,7 +294,7 @@ public subPub;public subData;public subProjects;public subOrg;public subPeople;
this.searchDatasetsComponent.searchUtils.totalResults = data; this.searchDatasetsComponent.searchUtils.totalResults = data;
}, },
err => { err => {
console.error(err); console.log(err);
} }
); );
}) })
@ -305,7 +305,7 @@ public subPub;public subData;public subProjects;public subOrg;public subPeople;
this.searchProjectsComponent.searchUtils.totalResults = data; this.searchProjectsComponent.searchUtils.totalResults = data;
}, },
err => { err => {
console.error(err); console.log(err);
} }
); );
}) })
@ -318,7 +318,7 @@ public subPub;public subData;public subProjects;public subOrg;public subPeople;
this.searchOrganizationsComponent.searchUtils.totalResults = data; this.searchOrganizationsComponent.searchUtils.totalResults = data;
}, },
err => { err => {
console.error(err); console.log(err);
} }
); );
}) })
@ -329,7 +329,7 @@ public subPub;public subData;public subProjects;public subOrg;public subPeople;
this.searchPeopleComponent.searchUtils.totalResults = data; this.searchPeopleComponent.searchUtils.totalResults = data;
}, },
err => { err => {
console.error(err); console.log(err);
} }
); );
}) })

View File

@ -68,7 +68,7 @@ export class SearchComponent {
this.page=page; this.page=page;
this.resultsNum = data['total-results']; this.resultsNum = data['total-results'];
}, },
err => console.error(err) err => console.log(err)
); );
} }

View File

@ -4,6 +4,7 @@ import { Subject } from 'rxjs/Subject';
import {AdvancedField, OPERATOR} from '../searchUtils/searchHelperClasses.class'; import {AdvancedField, OPERATOR} from '../searchUtils/searchHelperClasses.class';
import {SearchFields} from '../../utils/properties/searchFields'; import {SearchFields} from '../../utils/properties/searchFields';
import {Dates} from '../../utils/string-utils.class';
@Component({ @Component({
selector: 'advanced-search-form', selector: 'advanced-search-form',
@ -27,6 +28,8 @@ import {SearchFields} from '../../utils/properties/searchFields';
</button> </button>
</div> </div>
<input *ngIf = "fieldIdsMap[selectedField.id].type == 'keyword'" type="text" class="form-control" placeholder="Type keywords..." [(ngModel)]="selectedField.value" name="value[{{i}}]"> <input *ngIf = "fieldIdsMap[selectedField.id].type == 'keyword'" type="text" class="form-control" placeholder="Type keywords..." [(ngModel)]="selectedField.value" name="value[{{i}}]">
<input *ngIf = "fieldIdsMap[selectedField.id].type == 'year'" type="text" class="form-control" placeholder="Type Year..." [(ngModel)]="selectedField.value" name="value[{{i}}]" (keyup)=validateDate(i,selectedField.value)>
<!-- div *ngIf = "fieldIdsMap[selectedField.id].type == 'year' && !selectedField.valid" class="form-control-feedback">Not a valid year. Insert a date between 1000 - 3000</div-->
<div *ngIf = "fieldIdsMap[selectedField.id].type == 'vocabulary'" class="input-group"> <div *ngIf = "fieldIdsMap[selectedField.id].type == 'vocabulary'" class="input-group">
@ -38,9 +41,8 @@ import {SearchFields} from '../../utils/properties/searchFields';
<div *ngIf = "fieldIdsMap[selectedField.id].type == 'entity'" class="input-group"> <div *ngIf = "fieldIdsMap[selectedField.id].type == 'entity'" class="input-group">
<entities-autocomplete [entityType]=selectedField.param [selectedValue]=selectedField.value [showSelected]=true <entities-autocomplete [entityType]=selectedField.param [selectedValue]=selectedField.value [showSelected]=true
[placeHolderMessage] = "'Search for '+selectedField.name" [title] = "selectedField.name" [multipleSelections]=false [placeHolderMessage] = "'Search for '+selectedField.name" [title] = "selectedField.name" [multipleSelections]=false
(selectedValueChanged)="valueChanged($event,i)" (listUpdated) = "listUpdated($event,selectedField.id)" (selectedValueChanged)="valueChanged($event,i)" (listUpdated) = "listUpdated($event,selectedField.id)" >
</entities-autocomplete>
></entities-autocomplete>
</div> </div>
<div *ngIf = "fieldIdsMap[selectedField.id].type == 'boolean'" class="input-group"> <div *ngIf = "fieldIdsMap[selectedField.id].type == 'boolean'" class="input-group">
@ -135,6 +137,9 @@ export class AdvancedSearchFormComponent {
this.selectedFields[index].operatorId = operatorId; this.selectedFields[index].operatorId = operatorId;
this.selectedFields[index].operatorName = operatorName; this.selectedFields[index].operatorName = operatorName;
} }
validateDate(index: number, value: string){
this.selectedFields[index].valid = Dates.isValidYear(value);
}
fieldIdsChanged(index: number,id) { fieldIdsChanged(index: number,id) {
this.newFieldId = id; this.newFieldId = id;
@ -150,4 +155,5 @@ export class AdvancedSearchFormComponent {
listUpdated($event,fieldId:number){ listUpdated($event,fieldId:number){
this.fieldList[fieldId] = $event.value; this.fieldList[fieldId] = $event.value;
} }
} }

View File

@ -21,6 +21,8 @@ export class AdvancedField{
public value: string = ''; public value: string = '';
public operatorId: string; public operatorId: string;
public operatorName: string =""; public operatorName: string ="";
public valid: boolean = true;
constructor(id:string,param:string,name:string, type:string, value:string,operator:string){ constructor(id:string,param:string,name:string, type:string, value:string,operator:string){
this.id = id; this.id = id;

View File

@ -83,7 +83,7 @@ console.info("PAGE init = "+this.searchUtils.page);
this.searchUtils.totalResults = data; this.searchUtils.totalResults = data;
}, },
err => { err => {
console.error(err); console.log(err);
//TODO check erros (service not available, bad request) //TODO check erros (service not available, bad request)
// if( ){ // if( ){
// this.searchUtils.status = ErrorCodes.ERROR; // this.searchUtils.status = ErrorCodes.ERROR;
@ -105,7 +105,7 @@ console.info("PAGE init = "+this.searchUtils.page);
this.searchUtils.totalResults = data; this.searchUtils.totalResults = data;
}, },
err => { err => {
console.error(err); console.log(err);
//TODO check erros (service not available, bad request) //TODO check erros (service not available, bad request)
// if( ){ // if( ){
// this.searchUtils.status = ErrorCodes.ERROR; // this.searchUtils.status = ErrorCodes.ERROR;
@ -134,7 +134,7 @@ public getResultsForDeposit(id:string, type:string, page: number, size: number)
} }
}, },
err => { err => {
console.error(err); console.log(err);
//TODO check erros (service not available, bad request) //TODO check erros (service not available, bad request)
// if( ){ // if( ){
// this.searchUtils.status = ErrorCodes.ERROR; // this.searchUtils.status = ErrorCodes.ERROR;
@ -167,7 +167,7 @@ public getResultsForDeposit(id:string, type:string, page: number, size: number)
} }
}, },
err => { err => {
console.error(err); console.log(err);
//TODO check erros (service not available, bad request) //TODO check erros (service not available, bad request)
// if( ){ // if( ){
// this.searchUtils.status = ErrorCodes.ERROR; // this.searchUtils.status = ErrorCodes.ERROR;
@ -194,7 +194,7 @@ public getResultsForDeposit(id:string, type:string, page: number, size: number)
} }
}, },
err => { err => {
console.error(err); console.log(err);
//TODO check erros (service not available, bad request) //TODO check erros (service not available, bad request)
// if( ){ // if( ){
// this.searchUtils.status = ErrorCodes.ERROR; // this.searchUtils.status = ErrorCodes.ERROR;
@ -232,7 +232,7 @@ public getResultsForDeposit(id:string, type:string, page: number, size: number)
} }
}, },
err => { err => {
console.error(err); console.log(err);
//TODO check erros (service not available, bad request) //TODO check erros (service not available, bad request)
// if( ){ // if( ){
// this.searchUtils.status = ErrorCodes.ERROR; // this.searchUtils.status = ErrorCodes.ERROR;
@ -273,7 +273,7 @@ console.info("PAGE queryChanged = "+this.searchUtils.page);
} }
}, },
err => { err => {
console.error(err); console.log(err);
//TODO check erros (service not available, bad request) //TODO check erros (service not available, bad request)
// if( ){ // if( ){
// this.searchUtils.status = ErrorCodes.ERROR; // this.searchUtils.status = ErrorCodes.ERROR;

View File

@ -97,7 +97,7 @@ public getResultsForEntity(entity:string, id:string, page: number, size: number)
} }
}, },
err => { err => {
console.error(err); console.log(err);
//TODO check erros (service not available, bad request) //TODO check erros (service not available, bad request)
// if( ){ // if( ){
// this.searchUtils.status = ErrorCodes.ERROR; // this.searchUtils.status = ErrorCodes.ERROR;
@ -132,7 +132,7 @@ public getResultsForDataproviders(id:string, resultsFrom:string, page: number, s
} }
}, },
err => { err => {
console.error(err); console.log(err);
//TODO check erros (service not available, bad request) //TODO check erros (service not available, bad request)
// if( ){ // if( ){
// this.searchUtils.status = ErrorCodes.ERROR; // this.searchUtils.status = ErrorCodes.ERROR;
@ -180,7 +180,7 @@ private _getResults(parameters:string,refine:boolean, page: number, size: number
} }
}, },
err => { err => {
console.error(err); console.log(err);
//TODO check erros (service not available, bad request) //TODO check erros (service not available, bad request)
// if( ){ // if( ){
// this.searchUtils.status = ErrorCodes.ERROR; // this.searchUtils.status = ErrorCodes.ERROR;

View File

@ -94,7 +94,7 @@ export class SearchOrganizationsComponent {
} }
}, },
err => { err => {
console.error(err); console.log(err);
//TODO check erros (service not available, bad request) //TODO check erros (service not available, bad request)
// if( ){ // if( ){
// this.searchUtils.status = ErrorCodes.ERROR; // this.searchUtils.status = ErrorCodes.ERROR;

View File

@ -131,7 +131,7 @@ export class SearchPeopleComponent {
} }
}, },
err => { err => {
console.error(err); console.log(err);
console.info("error"); console.info("error");
//TODO check erros (service not available, bad request) //TODO check erros (service not available, bad request)
// if( ){ // if( ){
@ -167,7 +167,7 @@ private _getResults(parameters:string,refine:boolean, page: number, size: number
} }
}, },
err => { err => {
console.error(err); console.log(err);
//TODO check erros (service not available, bad request) //TODO check erros (service not available, bad request)
// if( ){ // if( ){
// this.searchUtils.status = ErrorCodes.ERROR; // this.searchUtils.status = ErrorCodes.ERROR;

View File

@ -100,7 +100,7 @@ export class SearchProjectsComponent {
} }
}, },
err => { err => {
console.error(err); console.log(err);
//TODO check erros (service not available, bad request) //TODO check erros (service not available, bad request)
// if( ){ // if( ){
// this.searchUtils.status = ErrorCodes.ERROR; // this.searchUtils.status = ErrorCodes.ERROR;
@ -126,7 +126,7 @@ export class SearchProjectsComponent {
} }
}, },
err => { err => {
console.error(err); console.log(err);
//TODO check erros (service not available, bad request) //TODO check erros (service not available, bad request)
// if( ){ // if( ){
// this.searchUtils.status = ErrorCodes.ERROR; // this.searchUtils.status = ErrorCodes.ERROR;

View File

@ -126,7 +126,7 @@ public getResultsForEntity(entity:string, id:string, page: number, size: number)
} }
}, },
err => { err => {
console.error(err); console.log(err);
//TODO check erros (service not available, bad request) //TODO check erros (service not available, bad request)
// if( ){ // if( ){
// this.searchUtils.status = ErrorCodes.ERROR; // this.searchUtils.status = ErrorCodes.ERROR;
@ -161,7 +161,7 @@ public getResultsForDataproviders(id:string, resultsFrom:string, page: number, s
} }
}, },
err => { err => {
console.error(err); console.log(err);
//TODO check erros (service not available, bad request) //TODO check erros (service not available, bad request)
// if( ){ // if( ){
// this.searchUtils.status = ErrorCodes.ERROR; // this.searchUtils.status = ErrorCodes.ERROR;
@ -209,7 +209,7 @@ private _getResults(parameters:string,refine:boolean, page: number, size: number
} }
}, },
err => { err => {
console.error(err); console.log(err);
//TODO check erros (service not available, bad request) //TODO check erros (service not available, bad request)
// if( ){ // if( ){
// this.searchUtils.status = ErrorCodes.ERROR; // this.searchUtils.status = ErrorCodes.ERROR;
@ -232,7 +232,7 @@ public getAggregatorResults(id:string, page: number, size: number){
} }
}, },
err => { err => {
console.error(err); console.log(err);
//TODO check erros (service not available, bad request) //TODO check erros (service not available, bad request)
// if( ){ // if( ){
// this.searchUtils.status = ErrorCodes.ERROR; // this.searchUtils.status = ErrorCodes.ERROR;
@ -267,7 +267,7 @@ public getAggregatorResults(id:string, page: number, size: number){
this.searchUtils.status = errorCodes.DONE; this.searchUtils.status = errorCodes.DONE;
}, },
err => { err => {
console.error(err); console.log(err);
//TODO check erros (service not available, bad request) //TODO check erros (service not available, bad request)
// if( ){ // if( ){
// this.searchUtils.status = ErrorCodes.ERROR; // this.searchUtils.status = ErrorCodes.ERROR;

View File

@ -116,7 +116,7 @@ export class ClaimsService {
private handleError (error: Response) { private handleError (error: Response) {
// in a real world app, we may send the error to some remote logging infrastructure // in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console // instead of just logging it to the console
console.error(error); console.log(error);
return Observable.throw(error || 'Server error'); return Observable.throw(error || 'Server error');
} }

View File

@ -82,7 +82,7 @@ export class ContextsService {
private handleError (error: Response) { private handleError (error: Response) {
// in a real world app, we may send the error to some remote logging infrastructure // in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console // instead of just logging it to the console
console.error(error); console.log(error);
return Observable.throw(error || 'Server error'); return Observable.throw(error || 'Server error');
} }
} }

View File

@ -20,7 +20,7 @@ export class DataProviderService {
let url = OpenaireProperties.getSearchAPIURLLast() + 'datasources/' +id +"?format=json"; let url = OpenaireProperties.getSearchAPIURLLast() + 'datasources/' +id +"?format=json";
let key = url; let key = url;
if (this._cache.has(key)) { if (this._cache.has(key)) {
return Observable.of(this._cache.get(key)); return Observable.of(this._cache.get(key)).map(res => this.parseDataProviderInfo(res));
} }
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
@ -30,12 +30,10 @@ export class DataProviderService {
res['oaf:datasource']['openairecompatibility'], res['oaf:datasource']['openairecompatibility'],
res['oaf:datasource']['accessinfopackage'], res['oaf:datasource']['accessinfopackage'],
res['oaf:datasource']['rels']['rel'] res['oaf:datasource']['rels']['rel']
]).map(res => this.parseDataProviderInfo(res)).do(res => { ]).do(res => {
this._cache.set(key, res); this._cache.set(key, res);
}) })
.do(res => { .map(res => this.parseDataProviderInfo(res));
this._cache.set(key, res);
});
} }
@ -58,7 +56,7 @@ export class DataProviderService {
private handleError (error: Response) { private handleError (error: Response) {
// in a real world app, we may send the error to some remote logging infrastructure // in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console // instead of just logging it to the console
console.error(error); console.log(error);
return Observable.throw(error || 'Server error'); return Observable.throw(error || 'Server error');
} }
@ -141,7 +139,7 @@ export class DataProviderService {
let length = data[4].length!=undefined ? data[4].length : 1; let length = data[4].length!=undefined ? data[4].length : 1;
for(let i=0; i<length; i++) { for(let i=0; i<length; i++) {
mydata = length > 1 ? data[4][i] : data[4]; mydata = data[4].length!=undefined ? data[4][i] : data[4];
if(mydata.hasOwnProperty("to")) { if(mydata.hasOwnProperty("to")) {
if(mydata['to'].class == "provides" && mydata['to'].type == "organization") { if(mydata['to'].class == "provides" && mydata['to'].type == "organization") {
//if(this.dataProviderInfo.organizations == undefined) { //if(this.dataProviderInfo.organizations == undefined) {

View File

@ -23,7 +23,7 @@ export class DatasetService {
let url = OpenaireProperties. getSearchAPIURLLast()+'datasets/'+id+"?format=json"; let url = OpenaireProperties. getSearchAPIURLLast()+'datasets/'+id+"?format=json";
let key = url; let key = url;
if (this._cache.has(key)) { if (this._cache.has(key)) {
return Observable.of(this._cache.get(key)); return Observable.of(this._cache.get(key)).map(res => this.parseDatasetInfo(res));
} }
return this.http.get(url) return this.http.get(url)
@ -40,11 +40,10 @@ export class DatasetService {
res['collectedfrom'], res['collectedfrom'],
res['context'], res['context'],
res['resulttype'] res['resulttype']
]) ]).do(res => {
.map(res => this.parseDatasetInfo(res))
.do(res => {
this._cache.set(key, res); this._cache.set(key, res);
}); })
.map(res => this.parseDatasetInfo(res));
} }
@ -54,20 +53,20 @@ export class DatasetService {
let url = OpenaireProperties.getMetricsAPIURL()+"results/"+id+"/clicks"; let url = OpenaireProperties.getMetricsAPIURL()+"results/"+id+"/clicks";
let key = url; let key = url;
if (this._cache.has(key)) { if (this._cache.has(key)) {
return Observable.of(this._cache.get(key)); return Observable.of(this._cache.get(key)).map(res => this.parseMetrics(res["downloads"], res["views"], res["total_downloads"], res["total_views"]));
} }
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
.map(res => this.parseMetrics(res["downloads"], res["views"], res["total_downloads"], res["total_views"]))
.do(res => { .do(res => {
this._cache.set(key, res); this._cache.set(key, res);
}); })
.map(res => this.parseMetrics(res["downloads"], res["views"], res["total_downloads"], res["total_views"]));
} }
private handleError (error: Response) { private handleError (error: Response) {
// in a real world app, we may send the error to some remote logging infrastructure // in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console // instead of just logging it to the console
console.error(error); console.log(error);
return Observable.throw(error || 'Server error'); return Observable.throw(error || 'Server error');
} }
@ -146,7 +145,7 @@ export class DatasetService {
let length = data[2].length!=undefined ? data[2].length : 1; let length = data[2].length!=undefined ? data[2].length : 1;
for(let i=0; i<length; i++) { for(let i=0; i<length; i++) {
mydata = length > 1 ? data[2][i] : data[2]; mydata = data[2].length!=undefined ? data[2][i] : data[2];
if(mydata.hasOwnProperty("to")) { if(mydata.hasOwnProperty("to")) {
if(mydata['to'].class == "hasAuthor") { if(mydata['to'].class == "hasAuthor") {
if(this.datasetInfo.authors == undefined) { if(this.datasetInfo.authors == undefined) {
@ -284,7 +283,7 @@ export class DatasetService {
let counter2 = 0; let counter2 = 0;
let mydata; let mydata;
for(let i=0; i<length; i++) { for(let i=0; i<length; i++) {
mydata = length > 1 ? data[3]['instance'][i] : data[3]['instance']; mydata = data[3]['instance'].length!=undefined ? data[3]['instance'][i] : data[3]['instance'];
if(this.datasetInfo.type == undefined) { if(this.datasetInfo.type == undefined) {
if(mydata.hasOwnProperty("instancetype")) { if(mydata.hasOwnProperty("instancetype")) {
@ -429,7 +428,7 @@ export class DatasetService {
let length = data[7].length!=undefined ? data[5].length : 1; let length = data[7].length!=undefined ? data[5].length : 1;
for(let i=0; i<length; i++) { for(let i=0; i<length; i++) {
mydata = length > 1 ? data[5][i] : data[5]; mydata = data[7].length!=undefined ? data[5][i] : data[5];
if(mydata.classid != "") { if(mydata.classid != "") {
if(mydata.inferred == true) { if(mydata.inferred == true) {
@ -474,7 +473,7 @@ export class DatasetService {
let mydata; let mydata;
let length = data[7].length!=undefined ? data[7].length : 1; let length = data[7].length!=undefined ? data[7].length : 1;
for(let i=0; i<length; i++) { for(let i=0; i<length; i++) {
mydata = length > 1 ? data[7][i] : data[7]; mydata = data[7].length!=undefined ? data[7][i] : data[7];
let link = OpenaireProperties.getsearchLinkToDataProvider(); let link = OpenaireProperties.getsearchLinkToDataProvider();
this.datasetInfo.collectedFrom[i] = {"name": "", "url": ""}; this.datasetInfo.collectedFrom[i] = {"name": "", "url": ""};
this.datasetInfo.collectedFrom[i]['name'] = mydata.name; this.datasetInfo.collectedFrom[i]['name'] = mydata.name;
@ -513,7 +512,7 @@ export class DatasetService {
let mydata; let mydata;
let length = data[8].length!=undefined ? data[8].length : 1; let length = data[8].length!=undefined ? data[8].length : 1;
for(let i=0; i<length; i++) { for(let i=0; i<length; i++) {
mydata = length > 1 ? data[8][i] : data[8]; mydata = data[8].length!=undefined ? data[8][i] : data[8];
if(mydata.hasOwnProperty("type") && mydata['type'] == "community") { if(mydata.hasOwnProperty("type") && mydata['type'] == "community") {
if(mydata.hasOwnProperty("category")) { if(mydata.hasOwnProperty("category")) {

View File

@ -183,7 +183,7 @@ private fetch (link,id,oafEntityType,type){
private handleError (error: Response) { private handleError (error: Response) {
// in a real world app, we may send the error to some remote logging infrastructure // in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console // instead of just logging it to the console
console.error(error); console.log(error);
return Observable.throw(error || 'Server error'); return Observable.throw(error || 'Server error');
} }
} }

View File

@ -71,7 +71,7 @@ export class OpenaireProjectsService {
private handleError (error: Response) { private handleError (error: Response) {
// in a real world app, we may send the error to some remote logging infrastructure // in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console // instead of just logging it to the console
console.error(error); console.log(error);
return Observable.throw(error || 'Server error'); return Observable.throw(error || 'Server error');
} }
private isJsonString(str) { private isJsonString(str) {

View File

@ -19,20 +19,18 @@ export class OrganizationService {
let url = OpenaireProperties. getSearchAPIURLLast()+'organizations/'+id+"?format=json"; let url = OpenaireProperties. getSearchAPIURLLast()+'organizations/'+id+"?format=json";
let key = url; let key = url;
// if (this._cache.has(key)) { if (this._cache.has(key)) {
// console.log("HEre in req after put in cache "+this._cache.has(key)); return Observable.of(this._cache.get(key)).map(res => this.parseOrganizationInfo(res));
// console.log("HEre in req get from cache " + this._cache.get(key).title.name); }
// return Observable.of(this._cache.get(key));
// }
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
.map(res => res['result']['metadata']['oaf:entity']['oaf:organization']) .map(res => res['result']['metadata']['oaf:entity']['oaf:organization'])
.map(res => [res, res['rels']['rel']]) .map(res => [res, res['rels']['rel']])
.map(res => this.parseOrganizationInfo(res))
.do(res => { .do(res => {
this._cache.set(key, res); this._cache.set(key, res);
}); })
.map(res => this.parseOrganizationInfo(res));
} }
@ -56,7 +54,7 @@ export class OrganizationService {
private handleError (error: Response) { private handleError (error: Response) {
// in a real world app, we may send the error to some remote logging infrastructure // in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console // instead of just logging it to the console
console.error(error); console.log(error);
return Observable.throw(error || 'Server error'); return Observable.throw(error || 'Server error');
} }
@ -91,7 +89,7 @@ export class OrganizationService {
let length = data[1].length!=undefined ? data[1].length : 1; let length = data[1].length!=undefined ? data[1].length : 1;
for(let i=0; i<length; i++) { for(let i=0; i<length; i++) {
mydata = length > 1 ? data[1][i] : data[1]; mydata = data[1].length!=undefined ? data[1][i] : data[1];
if(mydata.hasOwnProperty("to")) { if(mydata.hasOwnProperty("to")) {
if(mydata['to'].class == "isParticipant") { if(mydata['to'].class == "isParticipant") {
if(mydata.hasOwnProperty("funding")) { if(mydata.hasOwnProperty("funding")) {

View File

@ -36,15 +36,15 @@ export class PersonService {
let url = OpenaireProperties. getSearchAPIURLLast()+'people/'+id+"?format=json"; let url = OpenaireProperties. getSearchAPIURLLast()+'people/'+id+"?format=json";
let key = url; let key = url;
if (this._cache.has(key)) { if (this._cache.has(key)) {
return Observable.of(this._cache.get(key)); return Observable.of(this._cache.get(key)).map(res => this.parsePersonInfo(res));
} }
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
.map(res => res['result']['metadata']['oaf:entity']['oaf:person']) .map(res => res['result']['metadata']['oaf:entity']['oaf:person'])
.map(res => this.parsePersonInfo(res))
.do(res => { .do(res => {
this._cache.set(key, res); this._cache.set(key, res);
}); })
.map(res => this.parsePersonInfo(res));
@ -53,7 +53,7 @@ export class PersonService {
private handleError (error: Response) { private handleError (error: Response) {
// in a real world app, we may send the error to some remote logging infrastructure // in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console // instead of just logging it to the console
console.error(error); console.log(error);
return Observable.throw(error || 'Server error'); return Observable.throw(error || 'Server error');
} }

View File

@ -19,19 +19,20 @@ export class ProjectService {
let url = OpenaireProperties. getSearchAPIURLLast() + 'projects/'+id+"?format=json"; let url = OpenaireProperties. getSearchAPIURLLast() + 'projects/'+id+"?format=json";
let key = url; let key = url;
// if (this._cache.has(key)) { if (this._cache.has(key)) {
// return Observable.of(this._cache.get(key)); return Observable.of(this._cache.get(key))
// } .map(res => this.parseProjectInfo(res));
}
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
.map(res => res['result']['metadata']['oaf:entity']['oaf:project']) .map(res => res['result']['metadata']['oaf:entity']['oaf:project'])
.map(res => [res, .map(res => [res,
res['fundingtree'], res['fundingtree'],
res['rels']['rel']]) res['rels']['rel']])
.map(res => this.parseProjectInfo(res))
.do(res => { .do(res => {
this._cache.set(key, res); this._cache.set(key, res);
}); })
.map(res => this.parseProjectInfo(res));
} }
@ -59,23 +60,23 @@ export class ProjectService {
let url = OpenaireProperties. getSearchAPIURLLast()+'projects/'+id+"?format=json"; let url = OpenaireProperties. getSearchAPIURLLast()+'projects/'+id+"?format=json";
let key = url+'_projectDates'; let key = url+'_projectDates';
if (this._cache.has(key)) { if (this._cache.has(key)) {
return Observable.of(this._cache.get(key)); return Observable.of(this._cache.get(key)).map(res => this.parseProjectDates(id,res))
} }
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
.map(res => [res['result']['metadata']['oaf:entity']['oaf:project'], .map(res => [res['result']['metadata']['oaf:entity']['oaf:project'],
res['result']['metadata']['oaf:entity']['oaf:project']['fundingtree'], res['result']['metadata']['oaf:entity']['oaf:project']['fundingtree'],
res['result']['metadata']['oaf:entity']['oaf:project']['rels']['rel']]) res['result']['metadata']['oaf:entity']['oaf:project']['rels']['rel']])
.do(res => {
this._cache.set(key, res);
})
.map(res => this.parseProjectDates(id,res)) .map(res => this.parseProjectDates(id,res))
.do(res => {
this._cache.set(key, res);
});
} }
private handleError (error: Response) { private handleError (error: Response) {
// in a real world app, we may send the error to some remote logging infrastructure // in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console // instead of just logging it to the console
console.error(error); console.log(error);
return Observable.throw(error || 'Server error'); return Observable.throw(error || 'Server error');
} }

View File

@ -21,7 +21,7 @@ export class PublicationService {
let url = OpenaireProperties. getSearchAPIURLLast() + 'publications/' +id+"?format=json"; let url = OpenaireProperties. getSearchAPIURLLast() + 'publications/' +id+"?format=json";
let key = url; let key = url;
if (this._cache.has(key)) { if (this._cache.has(key)) {
return Observable.of(this._cache.get(key)); return Observable.of(this._cache.get(key)).map(res => this.parsePublicationInfo(res))
} }
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
@ -39,10 +39,10 @@ export class PublicationService {
(res['extraInfo']!= undefined && res['extraInfo']['citations']!= undefined)? res['extraInfo']['citations']['citation']:null, (res['extraInfo']!= undefined && res['extraInfo']['citations']!= undefined)? res['extraInfo']['citations']['citation']:null,
res['oaf:result']['context'] res['oaf:result']['context']
]) ])
.map(res => this.parsePublicationInfo(res))
.do(res => { .do(res => {
this._cache.set(key, res); this._cache.set(key, res);
}); })
.map(res => this.parsePublicationInfo(res));
} }
getMetrics (id: string):any { getMetrics (id: string):any {
@ -64,7 +64,7 @@ export class PublicationService {
private handleError (error: Response) { private handleError (error: Response) {
// in a real world app, we may send the error to some remote logging infrastructure // in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console // instead of just logging it to the console
console.error(error); console.log(error);
return Observable.throw(error || 'Server error'); return Observable.throw(error || 'Server error');
} }
@ -145,7 +145,7 @@ export class PublicationService {
let length = data[2].length!=undefined ? data[2].length : 1; let length = data[2].length!=undefined ? data[2].length : 1;
for(let i=0; i<length; i++) { for(let i=0; i<length; i++) {
mydata = length > 1 ? data[2][i] : data[2]; mydata = data[2].length!=undefined ? data[2][i] : data[2];
if(mydata.hasOwnProperty("to")) { if(mydata.hasOwnProperty("to")) {
if(mydata['to'].class == "hasAuthor") { if(mydata['to'].class == "hasAuthor") {
if(this.publicationInfo.authors == undefined) { if(this.publicationInfo.authors == undefined) {
@ -285,7 +285,7 @@ export class PublicationService {
let counter2 = 0; let counter2 = 0;
let mydata; let mydata;
for(let i=0; i<length; i++) { for(let i=0; i<length; i++) {
mydata = length > 1 ? data[3]['instance'][i] : data[3]['instance']; mydata = data[3]['instance'].length!=undefined ? data[3]['instance'][i] : data[3]['instance'];
if(mydata.hasOwnProperty("instancetype")) { if(mydata.hasOwnProperty("instancetype")) {
if(!types.has(mydata['instancetype'].classname)) { if(!types.has(mydata['instancetype'].classname)) {
@ -479,7 +479,7 @@ export class PublicationService {
let length = data[7].length!=undefined ? data[7].length : 1; let length = data[7].length!=undefined ? data[7].length : 1;
for(let i=0; i<length; i++) { for(let i=0; i<length; i++) {
mydata = length > 1 ? data[7][i] : data[7]; mydata = data[7].length!=undefined ? data[7][i] : data[7];
if(mydata.classid != "") { if(mydata.classid != "") {
if(mydata.inferred == true) { if(mydata.inferred == true) {
@ -524,7 +524,7 @@ export class PublicationService {
let mydata; let mydata;
let length = data[9].length!=undefined ? data[9].length : 1; let length = data[9].length!=undefined ? data[9].length : 1;
for(let i=0; i<length; i++) { for(let i=0; i<length; i++) {
mydata = length > 1 ? data[9][i] : data[9]; mydata = data[9].length!=undefined ? data[9][i] : data[9];
let link = OpenaireProperties.getsearchLinkToDataProvider(); let link = OpenaireProperties.getsearchLinkToDataProvider();
this.publicationInfo.collectedFrom[i] = {"name": "", "url": ""}; this.publicationInfo.collectedFrom[i] = {"name": "", "url": ""};
this.publicationInfo.collectedFrom[i]['name'] = mydata.name; this.publicationInfo.collectedFrom[i]['name'] = mydata.name;
@ -567,7 +567,7 @@ export class PublicationService {
let mydata; let mydata;
let length = data[10].length!=undefined ? data[10].length : 1; let length = data[10].length!=undefined ? data[10].length : 1;
for(let i=0; i<length; i++) { for(let i=0; i<length; i++) {
mydata = length > 1 ? data[10][i] : data[10]; mydata = data[10].length!=undefined ? data[10][i] : data[10];
let url; let url;
if(mydata.hasOwnProperty("id")) { if(mydata.hasOwnProperty("id")) {
@ -597,7 +597,7 @@ export class PublicationService {
let mydata; let mydata;
let length = data[11].length!=undefined ? data[11].length : 1; let length = data[11].length!=undefined ? data[11].length : 1;
for(let i=0; i<length; i++) { for(let i=0; i<length; i++) {
mydata = length > 1 ? data[11][i] : data[11]; mydata = data[11].length!=undefined ? data[11][i] : data[11];
if(mydata.hasOwnProperty("type") && mydata['type'] == "community") { if(mydata.hasOwnProperty("type") && mydata['type'] == "community") {
if(mydata.hasOwnProperty("category")) { if(mydata.hasOwnProperty("category")) {

View File

@ -22,16 +22,15 @@ export class RefineFieldResultsService {
let url = link+"&refine=true&page=1&size=0"; let url = link+"&refine=true&page=1&size=0";
let key = url; let key = url;
if (this._cache.has(key)) { if (this._cache.has(key)) {
return Observable.of(this._cache.get(key)); return Observable.of(this._cache.get(key)).map(res => this.parse(res,fieldName));
} }
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
.map(res => res['refineResults']) .map(res => res['refineResults'])
// .do(res => console.info(res))
.map(res => this.parse(res,fieldName))
.do(res => { .do(res => {
this._cache.set(key, res); this._cache.set(key, res);
}); })
.map(res => this.parse(res,fieldName));
} }
parse(data: any,fieldName:string):any { parse(data: any,fieldName:string):any {
@ -53,7 +52,7 @@ export class RefineFieldResultsService {
private handleError (error: Response) { private handleError (error: Response) {
// in a real world app, we may send the error to some remote logging infrastructure // in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console // instead of just logging it to the console
console.error(error); console.log(error);
return Observable.throw(error || 'Server error'); return Observable.throw(error || 'Server error');
} }
} }

View File

@ -77,7 +77,7 @@ export class SearchCrossrefService {
private handleError (error: Response) { private handleError (error: Response) {
// in a real world app, we may send the error to some remote logging infrastructure // in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console // instead of just logging it to the console
console.error(error); console.log(error);
return Observable.throw(error || 'Server error'); return Observable.throw(error || 'Server error');
} }

View File

@ -30,7 +30,7 @@ export class SearchDataciteService {
private handleError (error: Response) { private handleError (error: Response) {
// in a real world app, we may send the error to some remote logging infrastructure // in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console // instead of just logging it to the console
console.error(error); console.log(error);
return Observable.throw(error || 'Server error'); return Observable.throw(error || 'Server error');
} }
private extractData(res: Response) { private extractData(res: Response) {

View File

@ -27,15 +27,15 @@ export class SearchDataprovidersService {
let key = url; let key = url;
if (this._cache.has(key)) { if (this._cache.has(key)) {
return Observable.of(this._cache.get(key)); return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]);
} }
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
//.do(res => console.info(res)) //.do(res => console.info(res))
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")])
.do(res => { .do(res => {
this._cache.set(key, res); this._cache.set(key, res);
}); })
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]);
} }
//((oaftype exact datasource) and(collectedfromdatasourceid exact "openaire____::47ce9e9f4fad46e732cff06419ecaabb")) //((oaftype exact datasource) and(collectedfromdatasourceid exact "openaire____::47ce9e9f4fad46e732cff06419ecaabb"))
advancedSearchDataproviders (params: string, page: number, size: number ):any { advancedSearchDataproviders (params: string, page: number, size: number ):any {
@ -52,15 +52,15 @@ export class SearchDataprovidersService {
url += "&format=json"; url += "&format=json";
let key = url; let key = url;
if (this._cache.has(key)) { if (this._cache.has(key)) {
return Observable.of(this._cache.get(key)); return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results'])])
} }
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
//.do(res => console.info(res)) //.do(res => console.info(res))
.map(res => [res['meta'].total, this.parseResults(res['results'])])
.do(res => { .do(res => {
this._cache.set(key, res); this._cache.set(key, res);
}); })
.map(res => [res['meta'].total, this.parseResults(res['results'])])
} }
searchCompatibleDataproviders (params: string,refineParams:string, page: number, size: number, refineFields:string[] ):any { searchCompatibleDataproviders (params: string,refineParams:string, page: number, size: number, refineFields:string[] ):any {
let url = OpenaireProperties.getSearchResourcesAPIURL(); let url = OpenaireProperties.getSearchResourcesAPIURL();
@ -75,15 +75,15 @@ export class SearchDataprovidersService {
url += "&format=json"; url += "&format=json";
let key = url; let key = url;
if (this._cache.has(key)) { if (this._cache.has(key)) {
return Observable.of(this._cache.get(key)); return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]);
} }
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
//.do(res => console.info(res)) //.do(res => console.info(res))
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")])
.do(res => { .do(res => {
this._cache.set(key, res); this._cache.set(key, res);
}); })
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]);
} }
searchEntityRegistries (params: string,refineParams:string, page: number, size: number, refineFields:string[] ):any { searchEntityRegistries (params: string,refineParams:string, page: number, size: number, refineFields:string[] ):any {
let url = OpenaireProperties.getSearchResourcesAPIURL(); let url = OpenaireProperties.getSearchResourcesAPIURL();
@ -98,15 +98,15 @@ export class SearchDataprovidersService {
url += "&format=json"; url += "&format=json";
let key = url; let key = url;
if (this._cache.has(key)) { if (this._cache.has(key)) {
return Observable.of(this._cache.get(key)); return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]);
} }
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
//.do(res => console.info(res)) //.do(res => console.info(res))
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")])
.do(res => { .do(res => {
this._cache.set(key, res); this._cache.set(key, res);
}); })
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]);
} }
searchDataprovidersForDeposit (id: string,type:string, page: number, size: number):any { searchDataprovidersForDeposit (id: string,type:string, page: number, size: number):any {
@ -123,14 +123,14 @@ export class SearchDataprovidersService {
let key = url; let key = url;
if (this._cache.has(key)) { if (this._cache.has(key)) {
return Observable.of(this._cache.get(key)); return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results'])]);
} }
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
.map(res => [res['meta'].total, this.parseResults(res['results'])])
.do(res => { .do(res => {
this._cache.set(key, res); this._cache.set(key, res);
}); })
.map(res => [res['meta'].total, this.parseResults(res['results'])]);
} }
getDataProvidersforEntityRegistry(datasourceId: string, page: number, size: number ):any { getDataProvidersforEntityRegistry(datasourceId: string, page: number, size: number ):any {
let url = OpenaireProperties.getSearchResourcesAPIURL(); let url = OpenaireProperties.getSearchResourcesAPIURL();
@ -146,28 +146,28 @@ export class SearchDataprovidersService {
url += "&format=json"; url += "&format=json";
let key = url; let key = url;
if (this._cache.has(key)) { if (this._cache.has(key)) {
return Observable.of(this._cache.get(key)); return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results'])]);
} }
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
.map(res => [res['meta'].total, this.parseResults(res['results'])])
.do(res => { .do(res => {
this._cache.set(key, res); this._cache.set(key, res);
}); })
.map(res => [res['meta'].total, this.parseResults(res['results'])]);
} }
searchDataprovidersForEntity (params: string, page: number, size: number):any { searchDataprovidersForEntity (params: string, page: number, size: number):any {
let link = OpenaireProperties. getSearchAPIURLLast(); let link = OpenaireProperties. getSearchAPIURLLast();
let url = link+params+"/datasources?format=json"; let url = link+params+"/datasources?format=json";
let key = url; let key = url;
if (this._cache.has(key)) { if (this._cache.has(key)) {
return Observable.of(this._cache.get(key)); return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results'])]);
} }
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
.map(res => [res['meta'].total, this.parseResults(res['results'])])
.do(res => { .do(res => {
this._cache.set(key, res); this._cache.set(key, res);
}); })
.map(res => [res['meta'].total, this.parseResults(res['results'])]);
} }
searchDataprovidersCSV (params: string, refineParams:string, page: number, size: number):any { searchDataprovidersCSV (params: string, refineParams:string, page: number, size: number):any {
@ -185,15 +185,15 @@ export class SearchDataprovidersService {
let key = url; let key = url;
if (this._cache.has(key)) { if (this._cache.has(key)) {
return Observable.of(this._cache.get(key)); return Observable.of(this._cache.get(key)).map(res => this.parseResultsCSV(res['results']));
} }
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
//.do(res => console.info(res)) //.do(res => console.info(res))
.map(res => this.parseResultsCSV(res['results']))
.do(res => { .do(res => {
this._cache.set(key, res); this._cache.set(key, res);
}); })
.map(res => this.parseResultsCSV(res['results']));
} }
searchEntityRegistriesCSV (params: string,refineParams:string, page: number, size: number):any { searchEntityRegistriesCSV (params: string,refineParams:string, page: number, size: number):any {
@ -208,15 +208,15 @@ export class SearchDataprovidersService {
url += "&page="+(page - 1)+"&size="+size+"&format=json"; url += "&page="+(page - 1)+"&size="+size+"&format=json";
let key = url; let key = url;
if (this._cache.has(key)) { if (this._cache.has(key)) {
return Observable.of(this._cache.get(key)); return Observable.of(this._cache.get(key)).map(res => this.parseResultsCSV(res['results']));
} }
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
//.do(res => console.info(res)) //.do(res => console.info(res))
.map(res => this.parseResultsCSV(res['results']))
.do(res => { .do(res => {
this._cache.set(key, res); this._cache.set(key, res)
}); })
.map(res => this.parseResultsCSV(res['results']));
} }
searchCompatibleDataprovidersCSV (params: string,refineParams:string, page: number, size: number):any { searchCompatibleDataprovidersCSV (params: string,refineParams:string, page: number, size: number):any {
@ -231,15 +231,15 @@ export class SearchDataprovidersService {
url += "&page="+(page - 1)+"&size="+size+"&format=json"; url += "&page="+(page - 1)+"&size="+size+"&format=json";
let key = url; let key = url;
if (this._cache.has(key)) { if (this._cache.has(key)) {
return Observable.of(this._cache.get(key)); return Observable.of(this._cache.get(key)).map(res => this.parseResultsCSV(res['results']));
} }
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
//.do(res => console.info(res)) //.do(res => console.info(res))
.map(res => this.parseResultsCSV(res['results']))
.do(res => { .do(res => {
this._cache.set(key, res); this._cache.set(key, res);
}); })
.map(res => this.parseResultsCSV(res['results']));
} }
parseResults(data: any): SearchResult[] { parseResults(data: any): SearchResult[] {

View File

@ -29,15 +29,15 @@ export class SearchDatasetsService {
let key = url; let key = url;
if (this._cache.has(key)) { if (this._cache.has(key)) {
return Observable.of(this._cache.get(key)); return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "dataset")]);
} }
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
//.do(res => console.info(res)) //.do(res => console.info(res))
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "dataset")])
.do(res => { .do(res => {
this._cache.set(key, res); this._cache.set(key, res);
}); })
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "dataset")]);
} }
searchDatasetsByDois (DOIs: string[], refineParams:string, page: number, size: number, refineFields:string[] ):any { searchDatasetsByDois (DOIs: string[], refineParams:string, page: number, size: number, refineFields:string[] ):any {
let link = OpenaireProperties.getSearchAPIURLLast()+"datasets"; let link = OpenaireProperties.getSearchAPIURLLast()+"datasets";
@ -57,15 +57,15 @@ export class SearchDatasetsService {
let key = url; let key = url;
if (this._cache.has(key)) { if (this._cache.has(key)) {
return Observable.of(this._cache.get(key)); return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "dataset")]);
} }
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
//.do(res => console.info(res)) //.do(res => console.info(res))
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "dataset")])
.do(res => { .do(res => {
this._cache.set(key, res); this._cache.set(key, res);
}); })
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "dataset")]);
} }
advancedSearchDatasets (params: string, page: number, size: number ):any { advancedSearchDatasets (params: string, page: number, size: number ):any {
let url = OpenaireProperties.getSearchResourcesAPIURL(); let url = OpenaireProperties.getSearchResourcesAPIURL();
@ -96,14 +96,14 @@ export class SearchDatasetsService {
let url = link+params+"/datasets"+"?format=json"; let url = link+params+"/datasets"+"?format=json";
let key = url; let key = url;
if (this._cache.has(key)) { if (this._cache.has(key)) {
return Observable.of(this._cache.get(key)); return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results'])]);
} }
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
.map(res => [res['meta'].total, this.parseResults(res['results'])])
.do(res => { .do(res => {
this._cache.set(key, res); this._cache.set(key, res);
}); })
.map(res => [res['meta'].total, this.parseResults(res['results'])]);
} }
searchDatasetsForDataproviders(params: string, page: number, size: number):any { searchDatasetsForDataproviders(params: string, page: number, size: number):any {
@ -111,14 +111,14 @@ export class SearchDatasetsService {
let url = link+params+"&format=json"; let url = link+params+"&format=json";
let key = url; let key = url;
if (this._cache.has(key)) { if (this._cache.has(key)) {
return Observable.of(this._cache.get(key)); return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results'])]);
} }
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
.map(res => [res['meta'].total, this.parseResults(res['results'])])
.do(res => { .do(res => {
this._cache.set(key, res); this._cache.set(key, res);
}); })
.map(res => [res['meta'].total, this.parseResults(res['results'])]);
} }
parseResults(data: any): SearchResult[] { parseResults(data: any): SearchResult[] {

View File

@ -22,17 +22,17 @@ export class SearchOrcidService {
let url = OpenaireProperties.getSearchOrcidURL()+term+'/orcid-bio'; let url = OpenaireProperties.getSearchOrcidURL()+term+'/orcid-bio';
let key = url; let key = url;
if (this._cache.has(key)) { if (this._cache.has(key)) {
return Observable.of(this._cache.get(key)); return Observable.of(this._cache.get(key)).map(res => this.parseOrcidAuthor(res, authorIds, authorGivenNames, authorFamilyNames));
} }
return this.http.get(url, { headers: headers }) return this.http.get(url, { headers: headers })
.map(res => res.json()['orcid-profile']) .map(res => res.json()['orcid-profile'])
.map(res => [res['orcid-bio']['personal-details']['given-names'], .map(res => [res['orcid-bio']['personal-details']['given-names'],
res['orcid-bio']['personal-details']['family-name'], res['orcid-bio']['personal-details']['family-name'],
res['orcid-identifier']]) res['orcid-identifier']])
.map(res => this.parseOrcidAuthor(res, authorIds, authorGivenNames, authorFamilyNames))
.do(res => { .do(res => {
this._cache.set(key, res); this._cache.set(key, res);
}); })
.map(res => this.parseOrcidAuthor(res, authorIds, authorGivenNames, authorFamilyNames));
} }
searchOrcidAuthors (term: string, authorIds: string[], searchOrcidAuthors (term: string, authorIds: string[],
@ -45,14 +45,14 @@ export class SearchOrcidService {
let url = OpenaireProperties.getSearchOrcidURL()+'search/orcid-bio?defType=edismax&q='+term+'&qf=given-name^1.0+family-name^2.0+other-names^1.0+credit-name^1.0&start=0&rows=10'; let url = OpenaireProperties.getSearchOrcidURL()+'search/orcid-bio?defType=edismax&q='+term+'&qf=given-name^1.0+family-name^2.0+other-names^1.0+credit-name^1.0&start=0&rows=10';
let key = url; let key = url;
if (this._cache.has(key)) { if (this._cache.has(key)) {
return Observable.of(this._cache.get(key)); return Observable.of(this._cache.get(key)).map(res => this.parseOrcidAuthors(res, authorIds, authorGivenNames, authorFamilyNames));
} }
return this.http.get(url, { headers: headers }) return this.http.get(url, { headers: headers })
.map(res => res.json()['orcid-search-results']['orcid-search-result']) .map(res => res.json()['orcid-search-results']['orcid-search-result'])
.map(res => this.parseOrcidAuthors(res, authorIds, authorGivenNames, authorFamilyNames))
.do(res => { .do(res => {
this._cache.set(key, res); this._cache.set(key, res);
}); })
.map(res => this.parseOrcidAuthors(res, authorIds, authorGivenNames, authorFamilyNames));
} }
@ -109,7 +109,7 @@ export class SearchOrcidService {
length = data.length!=undefined ? data.length : 1; length = data.length!=undefined ? data.length : 1;
for(let i=0; i<length; i++) { for(let i=0; i<length; i++) {
mydata = length > 1 ? data[i] : data; mydata = data.length!=undefined ? data[i] : data;
if(mydata.hasOwnProperty("orcid-profile")) { if(mydata.hasOwnProperty("orcid-profile")) {
if(mydata['orcid-profile'].hasOwnProperty("orcid-identifier")) { if(mydata['orcid-profile'].hasOwnProperty("orcid-identifier")) {

View File

@ -53,15 +53,15 @@ export class SearchOrganizationsService {
let key = url; let key = url;
if (this._cache.has(key)) { if (this._cache.has(key)) {
return Observable.of(this._cache.get(key)); return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "organization")]);
} }
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
//.do(res => console.info(res)) //.do(res => console.info(res))
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "organization")])
.do(res => { .do(res => {
this._cache.set(key, res); this._cache.set(key, res);
}); })
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "organization")]);
} }
advancedSearchOrganizations (params: string, page: number, size: number ):any { advancedSearchOrganizations (params: string, page: number, size: number ):any {
let url = OpenaireProperties.getSearchResourcesAPIURL(); let url = OpenaireProperties.getSearchResourcesAPIURL();
@ -77,15 +77,15 @@ export class SearchOrganizationsService {
url += "&format=json"; url += "&format=json";
let key = url; let key = url;
if (this._cache.has(key)) { if (this._cache.has(key)) {
return Observable.of(this._cache.get(key)); return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results'])]);
} }
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
//.do(res => console.info(res)) //.do(res => console.info(res))
.map(res => [res['meta'].total, this.parseResults(res['results'])])
.do(res => { .do(res => {
this._cache.set(key, res); this._cache.set(key, res);
}); })
.map(res => [res['meta'].total, this.parseResults(res['results'])]);
} }
parseResults(data: any): SearchResult[] { parseResults(data: any): SearchResult[] {
let results: SearchResult[] = []; let results: SearchResult[] = [];

View File

@ -30,16 +30,16 @@ export class SearchPeopleService {
url += "&page="+(page-1)+"&size="+size + "&format=json"; url += "&page="+(page-1)+"&size="+size + "&format=json";
let key = url; let key = url;
if (this._cache.has(key)) { if (this._cache.has(key)) {
return Observable.of(this._cache.get(key)); return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "person")]);
} }
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
//.do(res => console.info(res)) //.do(res => console.info(res))
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "person")])
.do(res => { .do(res => {
this._cache.set(key, res); this._cache.set(key, res);
}); })
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "person")]);
} }
advancedSearchPeople (params: string, page: number, size: number ):any { advancedSearchPeople (params: string, page: number, size: number ):any {
let url = OpenaireProperties.getSearchResourcesAPIURL(); let url = OpenaireProperties.getSearchResourcesAPIURL();
@ -55,15 +55,15 @@ export class SearchPeopleService {
url += "&format=json"; url += "&format=json";
let key = url; let key = url;
if (this._cache.has(key)) { if (this._cache.has(key)) {
return Observable.of(this._cache.get(key)); return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results'])]);
} }
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
//.do(res => console.info(res)) //.do(res => console.info(res))
.map(res => [res['meta'].total, this.parseResults(res['results'])])
.do(res => { .do(res => {
this._cache.set(key, res); this._cache.set(key, res);
}); })
.map(res => [res['meta'].total, this.parseResults(res['results'])]);
} }
parseResults(data: any): SearchResult[] { parseResults(data: any): SearchResult[] {
let results: SearchResult[] = []; let results: SearchResult[] = [];
@ -80,7 +80,7 @@ export class SearchPeopleService {
result['title'].name = resData.fullname; result['title'].name = resData.fullname;
result['title'].url = OpenaireProperties.getsearchLinkToPerson(); result['title'].url = OpenaireProperties.getsearchLinkToPerson();
result['title'].url += length > 1 ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier']; result['title'].url += Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
results.push(result); results.push(result);
} }

View File

@ -31,16 +31,16 @@ export class SearchProjectsService {
url += "&page="+(page-1)+"&size="+size + "&format=json"; url += "&page="+(page-1)+"&size="+size + "&format=json";
let key = url; let key = url;
if (this._cache.has(key)) { if (this._cache.has(key)) {
return Observable.of(this._cache.get(key)); return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "project")]);
} }
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
//.do(res => console.info(res)) //.do(res => console.info(res))
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "project")])
.do(res => { .do(res => {
this._cache.set(key, res); this._cache.set(key, res);
}); })
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "project")]);
} }
getProjectsforDataProvider (datasourceId: string, page: number, size: number ):any { getProjectsforDataProvider (datasourceId: string, page: number, size: number ):any {
let url = OpenaireProperties.getSearchResourcesAPIURL(); let url = OpenaireProperties.getSearchResourcesAPIURL();
@ -56,14 +56,14 @@ export class SearchProjectsService {
url += "&format=json"; url += "&format=json";
let key = url; let key = url;
if (this._cache.has(key)) { if (this._cache.has(key)) {
return Observable.of(this._cache.get(key)); return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results'])]);
} }
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
.map(res => [res['meta'].total, this.parseResults(res['results'])])
.do(res => { .do(res => {
this._cache.set(key, res); this._cache.set(key, res);
}); })
.map(res => [res['meta'].total, this.parseResults(res['results'])]);
} }
advancedSearchProjects (params: string, page: number, size: number ):any { advancedSearchProjects (params: string, page: number, size: number ):any {
let url = OpenaireProperties.getSearchResourcesAPIURL(); let url = OpenaireProperties.getSearchResourcesAPIURL();
@ -79,28 +79,28 @@ export class SearchProjectsService {
url += "&format=json"; url += "&format=json";
let key = url; let key = url;
if (this._cache.has(key)) { if (this._cache.has(key)) {
return Observable.of(this._cache.get(key)); return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results'])]);
} }
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
//.do(res => console.info(res)) //.do(res => console.info(res))
.map(res => [res['meta'].total, this.parseResults(res['results'])])
.do(res => { .do(res => {
this._cache.set(key, res); this._cache.set(key, res);
}); })
.map(res => [res['meta'].total, this.parseResults(res['results'])]);
} }
getFunders():any { getFunders():any {
let url = OpenaireProperties.getSearchAPIURLLast()+"projects?refine=true&fields=funderid&size=0"+ "&format=json";; let url = OpenaireProperties.getSearchAPIURLLast()+"projects?refine=true&fields=funderid&size=0"+ "&format=json";;
let key = url; let key = url;
if (this._cache.has(key)) { if (this._cache.has(key)) {
return Observable.of(this._cache.get(key)); return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, res['refineResults']['funderid']]);
} }
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
.map(res => [res['meta'].total, res['refineResults']['funderid']])
.do(res => { .do(res => {
this._cache.set(key, res); this._cache.set(key, res);
}); })
.map(res => [res['meta'].total, res['refineResults']['funderid']]);
} }
@ -143,7 +143,7 @@ export class SearchProjectsService {
// result['title'].name = resData['title'].content; // result['title'].name = resData['title'].content;
// } // }
result['title'].url = OpenaireProperties.getsearchLinkToProject(); result['title'].url = OpenaireProperties.getsearchLinkToProject();
result['title'].url += length > 1 ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier']; result['title'].url += Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
if(resData['rels'].hasOwnProperty("rel")) { if(resData['rels'].hasOwnProperty("rel")) {
let relLength = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'].length : 1; let relLength = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'].length : 1;

View File

@ -31,16 +31,16 @@ export class SearchPublicationsService {
let key = url; let key = url;
if (this._cache.has(key)) { if (this._cache.has(key)) {
return Observable.of(this._cache.get(key)); return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "publication")]);
} }
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
.do(res => console.info(res)) .do(res => console.info(res))
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "publication")])
.do(res => { .do(res => {
this._cache.set(key, res); this._cache.set(key, res);
}); })
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "publication")]);
} }
searchAggregators (params: string, refineParams:string, page: number, size: number ):any { searchAggregators (params: string, refineParams:string, page: number, size: number ):any {
@ -58,15 +58,15 @@ export class SearchPublicationsService {
let key = url; let key = url;
if (this._cache.has(key)) { if (this._cache.has(key)) {
return Observable.of(this._cache.get(key)); return Observable.of(this._cache.get(key)).map(res => this.parseRefineResults(res['refineResults']));
} }
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
.map(res => this.parseRefineResults(res['refineResults']))
.do(res => { .do(res => {
this._cache.set(key, res); this._cache.set(key, res);
}); })
.map(res => this.parseRefineResults(res['refineResults']));
} }
searchPublicationsByDois (DOIs: string[], refineParams:string, page: number, size: number, refineFields:string[] ):any { searchPublicationsByDois (DOIs: string[], refineParams:string, page: number, size: number, refineFields:string[] ):any {
@ -89,16 +89,16 @@ export class SearchPublicationsService {
let key = url; let key = url;
if (this._cache.has(key)) { if (this._cache.has(key)) {
return Observable.of(this._cache.get(key)); return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "publication")]);
} }
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
//.do(res => console.info(res)) //.do(res => console.info(res))
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "publication")])
.do(res => { .do(res => {
this._cache.set(key, res); this._cache.set(key, res);
}); })
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "publication")]);
} }
advancedSearchPublications (params: string, page: number, size: number ):any { advancedSearchPublications (params: string, page: number, size: number ):any {
@ -115,15 +115,15 @@ export class SearchPublicationsService {
url += "&format=json"; url += "&format=json";
let key = url; let key = url;
if (this._cache.has(key)) { if (this._cache.has(key)) {
return Observable.of(this._cache.get(key)); return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results'])]);
} }
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
//.do(res => console.info(res)) //.do(res => console.info(res))
.map(res => [res['meta'].total, this.parseResults(res['results'])])
.do(res => { .do(res => {
this._cache.set(key, res); this._cache.set(key, res);
}); })
.map(res => [res['meta'].total, this.parseResults(res['results'])]);
} }
searchPublicationsForEntity (params: string, page: number, size: number):any { searchPublicationsForEntity (params: string, page: number, size: number):any {
let link = OpenaireProperties.getSearchAPIURLLast(); let link = OpenaireProperties.getSearchAPIURLLast();
@ -131,15 +131,15 @@ export class SearchPublicationsService {
let key = url; let key = url;
if (this._cache.has(key)) { if (this._cache.has(key)) {
return Observable.of(this._cache.get(key)); return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results'])]);
} }
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
.map(res => [res['meta'].total, this.parseResults(res['results'])])
.do(res => { .do(res => {
this._cache.set(key, res); this._cache.set(key, res);
}); })
.map(res => [res['meta'].total, this.parseResults(res['results'])]);
} }
searchPublicationsForDataproviders(params: string, page: number, size: number):any { searchPublicationsForDataproviders(params: string, page: number, size: number):any {
@ -147,14 +147,14 @@ export class SearchPublicationsService {
let url = link+params+ "&page="+(page-1)+"&size="+size + "&format=json"; let url = link+params+ "&page="+(page-1)+"&size="+size + "&format=json";
let key = url; let key = url;
if (this._cache.has(key)) { if (this._cache.has(key)) {
return Observable.of(this._cache.get(key)); return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results'])]);
} }
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
.map(res => [res['meta'].total, this.parseResults(res['results'])])
.do(res => { .do(res => {
this._cache.set(key, res); this._cache.set(key, res);
}); })
.map(res => [res['meta'].total, this.parseResults(res['results'])]);
} }
searchPublicationsCSV (params: string, refineParams:string, page: number, size: number):any { searchPublicationsCSV (params: string, refineParams:string, page: number, size: number):any {
@ -172,16 +172,16 @@ export class SearchPublicationsService {
let key = url; let key = url;
if (this._cache.has(key)) { if (this._cache.has(key)) {
return Observable.of(this._cache.get(key)); return Observable.of(this._cache.get(key)).map(res => this.parseResultsCSV(res['results']));
} }
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
//.do(res => console.info(res)) //.do(res => console.info(res))
.map(res => this.parseResultsCSV(res['results']))
.do(res => { .do(res => {
this._cache.set(key, res); this._cache.set(key, res);
}); })
.map(res => this.parseResultsCSV(res['results']));
} }

View File

@ -63,7 +63,22 @@ export class TestComponent {
// this.lan = this._vocabulariesService.getLanguages(); // this.lan = this._vocabulariesService.getLanguages();
// this.lan = this._vocabulariesService.getVocabularyFromService("dnet:languages.json"); // this.lan = this._vocabulariesService.getVocabularyFromService("dnet:languages.json");
// this.countries = this._vocabulariesService.getVocabularyFromService("dnet:countries.json"); // this.countries = this._vocabulariesService.getVocabularyFromService("dnet:countries.json");
var year ="1000";
console.info(year+" "+ Dates.isValidYear(year));
year ="600a.j";
console.info(year+" "+ Dates.isValidYear(year));
year ="qw000";
console.info(year+" "+ Dates.isValidYear(year));
year ="00444";
console.info(year+" "+ Dates.isValidYear(year));
year ="1998...";
console.info(year+" "+ Dates.isValidYear(year));
year ="2017";
console.info(year+" "+ Dates.isValidYear(year));
year ="3000";
console.info(year+" "+ Dates.isValidYear(year));
year ="3020";
console.info(year+" "+ Dates.isValidYear(year));
if( typeof localStorage !== 'undefined') { if( typeof localStorage !== 'undefined') {
this.user.email = localStorage.getItem("email"); this.user.email = localStorage.getItem("email");
@ -77,7 +92,7 @@ export class TestComponent {
// //
// }, // },
// err => { // err => {
// console.error(err) // console.log(err)
// //
// } // }
// ); // );
@ -88,7 +103,7 @@ export class TestComponent {
// //
// }, // },
// err => { // err => {
// console.error(err) // console.log(err)
// //
// } // }
// ); // );
@ -99,7 +114,7 @@ export class TestComponent {
// //
// }, // },
// err => { // err => {
// console.error(err) // console.log(err)
// //
// } // }
// ); // );

View File

@ -40,12 +40,12 @@ export class OpenaireProperties {
// private searchAPIURL = "http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2.0/api/"; // private searchAPIURL = "http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2.0/api/";
// private static searchAPIURL = "http://scoobydoo.di.uoa.gr:8181/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/"; // private static searchAPIURL = "http://scoobydoo.di.uoa.gr:8181/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/";
// private static searchAPIURLLAst = "http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/" private static searchAPIURLLAst = "http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/"
private static searchAPIURLLAst = "http://scoobydoo.di.uoa.gr:8181/dnet-functionality-services-2.0.0-SNAPSHOT-new/rest/v2/api/"; // private static searchAPIURLLAst = "http://scoobydoo.di.uoa.gr:8181/dnet-functionality-services-2.0.0-SNAPSHOT-new/rest/v2/api/";
// private static searchResourcesAPIURL = "http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/resources"; private static searchResourcesAPIURL = "http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/resources";
private static searchResourcesAPIURL = "http://scoobydoo.di.uoa.gr:8181/dnet-functionality-services-2.0.0-SNAPSHOT-new/rest/v2/api/resources"; // private static searchResourcesAPIURL = "http://scoobydoo.di.uoa.gr:8181/dnet-functionality-services-2.0.0-SNAPSHOT-new/rest/v2/api/resources";
//private static searchServiveURL = "http://astero.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/"; //private static searchServiveURL = "http://astero.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/";
private static searchServiveURL = "http://scoobydoo.di.uoa.gr:8181/dnet-functionality-services-2.0.0-SNAPSHOT/"; private static searchServiveURL = "http://scoobydoo.di.uoa.gr:8181/dnet-functionality-services-2.0.0-SNAPSHOT/";

View File

@ -5,7 +5,7 @@ export class SearchFields {
//In case Datasets should display different fields, use seperate tables for fields //In case Datasets should display different fields, use seperate tables for fields
public RESULT_REFINE_FIELDS = ["instancetypename", "resultlanguagename", "community","relproject", "relfunderid", public RESULT_REFINE_FIELDS = ["instancetypename", "resultlanguagename", "community","relproject", "relfunderid",
"relfundinglevel0_id","relfundinglevel1_id","relfundinglevel2_id", "relfundinglevel0_id","relfundinglevel1_id","relfundinglevel2_id",
"resultacceptanceyear","resultbestlicense","collectedfrom"]; "resultacceptanceyear","resultbestlicense"];//,"collectedfrom"];
public RESULT_ADVANCED_FIELDS:string[] = ["q","resulttitle","relperson","resultpublisher","instancetypenameid", public RESULT_ADVANCED_FIELDS:string[] = ["q","resulttitle","relperson","resultpublisher","instancetypenameid",
"resultlanguageid", "community","relprojectid", "relfunderid", "resultlanguageid", "community","relprojectid", "relfunderid",
@ -34,7 +34,7 @@ export class SearchFields {
["relfundinglevel0_id"]:{name:"Funding Stream", type:"refine", param:"funderlv0", equalityOperator: " exact "}, ["relfundinglevel0_id"]:{name:"Funding Stream", type:"refine", param:"funderlv0", equalityOperator: " exact "},
["relfundinglevel1_id"]:{name:"Funding Substream level 1", type:"refine", param:"funderlv1", equalityOperator: " exact "}, ["relfundinglevel1_id"]:{name:"Funding Substream level 1", type:"refine", param:"funderlv1", equalityOperator: " exact "},
["relfundinglevel2_id"]:{name:"Funding Substream level 2", type:"refine", param:"funderlv2", equalityOperator: " exact "}, ["relfundinglevel2_id"]:{name:"Funding Substream level 2", type:"refine", param:"funderlv2", equalityOperator: " exact "},
["resultacceptanceyear"]:{name:"Year", type:"refine", param:"year", equalityOperator: " exact "}, ["resultacceptanceyear"]:{name:"Year", type:"year", param:"year", equalityOperator: " exact "},
["resultbestlicense"]:{name:"Access Mode", type:"refine", param:"access", equalityOperator: " exact "}, ["resultbestlicense"]:{name:"Access Mode", type:"refine", param:"access", equalityOperator: " exact "},
["resultbestlicenseid"]:{name:"Access Mode", type:"vocabulary", param:"access", equalityOperator: " exact "}, ["resultbestlicenseid"]:{name:"Access Mode", type:"vocabulary", param:"access", equalityOperator: " exact "},
["collectedfrom"]:{name:"Datasource", type:"refine", param:"datasource", equalityOperator: " exact "}, ["collectedfrom"]:{name:"Datasource", type:"refine", param:"datasource", equalityOperator: " exact "},
@ -59,8 +59,8 @@ export class SearchFields {
["fundinglevel0_id"]:{name:"Funding Stream", type:"refine", param:"funderlv0", equalityOperator: " exact "}, ["fundinglevel0_id"]:{name:"Funding Stream", type:"refine", param:"funderlv0", equalityOperator: " exact "},
["fundinglevel1_id"]:{name:"Funding Substream level 1", type:"refine", param:"funderlv1", equalityOperator: " exact "}, ["fundinglevel1_id"]:{name:"Funding Substream level 1", type:"refine", param:"funderlv1", equalityOperator: " exact "},
["fundinglevel2_id"]:{name:"Funding Substream level 2", type:"refine", param:"funderlv2", equalityOperator: " exact "}, ["fundinglevel2_id"]:{name:"Funding Substream level 2", type:"refine", param:"funderlv2", equalityOperator: " exact "},
["projectstartyear"]:{name:"Start Year", type:"refine", param:"startyear", equalityOperator: " exact "}, ["projectstartyear"]:{name:"Start Year", type:"year", param:"startyear", equalityOperator: " exact "},
["projectendyear"]:{name:"End Year", type:"refine", param:"endyear", equalityOperator: " exact "}, ["projectendyear"]:{name:"End Year", type:"year", param:"endyear", equalityOperator: " exact "},
["projectecsc39"]:{name:"Special Clause 39", type:"boolean", param:"sc39", equalityOperator: " exact "}, ["projectecsc39"]:{name:"Special Clause 39", type:"boolean", param:"sc39", equalityOperator: " exact "},
["projectcode"]:{name:"Project Code", type:"keyword", param:"code", equalityOperator: " exact "}, ["projectcode"]:{name:"Project Code", type:"keyword", param:"code", equalityOperator: " exact "},

View File

@ -89,7 +89,7 @@ export class StaticAutoCompleteComponent {
}, },
err => { err => {
console.error(err); console.log(err);
this.warningMessage = "An Error occured..." this.warningMessage = "An Error occured..."
} }
); );

View File

@ -1,5 +1,15 @@
export class Dates { export class Dates {
public static isValidYear(yearString){
// First check for the pattern
if(!/^\d{4}$/.test(yearString))
return false;
var year = parseInt(yearString, 10);
// Check the ranges of month and year
if(year < 1000 || year > 3000 )
return false;
return true;
}
//format YYYY-MM-DD //format YYYY-MM-DD
public static isValidDate(dateString) public static isValidDate(dateString)
{ {
@ -11,10 +21,13 @@ export class Dates {
var parts = dateString.split("-"); var parts = dateString.split("-");
var day = parseInt(parts[2], 10); var day = parseInt(parts[2], 10);
var month = parseInt(parts[1], 10); var month = parseInt(parts[1], 10);
var year = parseInt(parts[0], 10); var year = parseInt(parts[0], 10);
if(!this.isValidYear(parts[0])){
return false;
}
// Check the ranges of month and year // Check the ranges of month and year
if(year < 1000 || year > 3000 || month == 0 || month > 12) if( month == 0 || month > 12)
return false; return false;
var monthLength = [ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ]; var monthLength = [ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ];