All the links you provided will be published in the OpenAIRE platform.
@@ -60,6 +73,32 @@ export class ClaimInsertComponent {
this.subscriptions.push(this.route.queryParams.subscribe(params => {
this.params = params;
}));
+ if(localStorage.getItem(this.localStoragePrefix + "claimsJob")){
+ this.claimsJob = JSON.parse(localStorage.getItem(this.localStoragePrefix + "claimsJob"));
+ this.feedRecordsJob = JSON.parse(localStorage.getItem(this.localStoragePrefix + "feedRecordsJob"));
+ if(this.claimsJob.status != "COMPLETE"){
+ this.claiming = true;
+ let loadingTimerSubscription = timer(0, 1000).pipe(
+ map(() => {
+ if(this.loading) {
+ this.loading.open();
+ loadingTimerSubscription.unsubscribe();
+ }
+ })
+ ).subscribe();
+ this.subscriptions.push(loadingTimerSubscription);
+
+ let timerSubscription = timer(0, 10000).pipe(
+ map(() => {
+ this.getStatus(); // load data contains the http request
+ })
+ ).subscribe();
+ this.subscriptions.push(timerSubscription);
+ }else{
+ this.claimsJob = null;
+ }
+ }
+
}
params = {};
@@ -84,15 +123,15 @@ export class ClaimInsertComponent {
private errorInClaims: ClaimRecord2Insert[] = [];
private insertedRecords = [];
private errorInRecords = [];
-
+ public claimsJob;
+ public feedRecordsJob;
+ public claims2Insert;
+ public records2Insert
public insert() {
this.confirmOpen();
}
saveAndNavigate(){
- localStorage.setItem(this.localStoragePrefix + "results", JSON.stringify(this.results));
- if (this.sources != null) {
- localStorage.setItem(this.localStoragePrefix + "sources", JSON.stringify(this.sources));
- }
+ this.saveLocalStorage();
this._router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
@@ -177,12 +216,15 @@ export class ClaimInsertComponent {
//first call direct index service - when call is done (success or error) call isertBulkClaims method to insert claims in DB
// console.log("directclaims");
// console.log(directclaims);
- if (directclaims.length > 0 && this.properties.environment != "development"){
+ if (directclaims.length > 0/* && this.properties.environment != "development"*/){
this.subscriptions.push(this.claimService.insertDirectRecords(directclaims, this.properties.claimsAPIURL).subscribe(
data => {
- this.insertedRecords = data.insertedIds;
-
- this.errorInRecords = data.errorInClaims;
+ this.feedRecordsJob = data.data;
+ this.records2Insert = directclaims.length;
+ console.log(data);
+ // this.insertedRecords = data.insertedIds;
+ //
+ // this.errorInRecords = data.errorInClaims;
this.isertBulkClaims(claims);
},
err => {
@@ -190,12 +232,12 @@ export class ClaimInsertComponent {
if (err.code && err.code == 403) {
this.saveAndNavigate();
}
- if (err.insertedIds && err.insertedIds.length > 0) {
+ /* if (err.insertedIds && err.insertedIds.length > 0) {
this.insertedRecords = err.insertedIds;
}
if (err.errorInClaims && err.errorInClaims.length > 0) {
this.errorInRecords = err.errorInClaims;
- }
+ }*/
this.isertBulkClaims(claims);
ClaimInsertComponent.handleError("Error inserting direct records: " + JSON.stringify(directclaims), err);
@@ -209,30 +251,18 @@ export class ClaimInsertComponent {
}
private isertBulkClaims(claims: ClaimRecord2Insert[]) {
- console.log("claims");
- console.log(claims);
this.errors.splice(0, this.errors.length);
this.subscriptions.push(this.claimService.insertBulkClaims(claims, this.properties.claimsAPIURL).subscribe(
data => {
- this.insertedClaims = data.insertedIds;
- this.errorInClaims = data.errorInClaims;
- //TODO remove - testing having errors in claims
- // this.insertedClaims.pop();
- // this.insertedClaims.pop();
- // this.errorInClaims.push(claims[1]);
- // this.insertedClaims.splice(0,this.insertedClaims.length);
- // this.errorInClaims = claims;
- //remove till here
-
- if (claims.length != this.insertedClaims.length) {
- let error: ClaimsErrorMessage = new ClaimsErrorMessage();
- error.type = "claimServiceFail2Insert";
- error.inserted = this.insertedClaims.length;
- error.failed = this.errorInClaims.length;
- this.createErrorMessagesPerEntity((this.insertedClaims.length == 0));
- this.errors.push(error);
- }
- this.afterclaimsInsertion();
+ this.claims2Insert = claims.length;
+ this.claimsJob = data.data;
+ this.saveLocalStorage();
+ let timerSubscription = timer(0, 10000).pipe(
+ map(() => {
+ this.getStatus(); // load data contains the http request
+ })
+ ).subscribe();
+ this.subscriptions.push(timerSubscription);
},
err => {
err = err && err.error?err.error:err;
@@ -335,13 +365,16 @@ export class ClaimInsertComponent {
}
private afterclaimsInsertion() {
-
- this.loading.close();
this.claiming = false;
+ this.loading.close();
+
if (this.errorInClaims.length == 0 && this.insertedClaims.length > 0) {
localStorage.removeItem(this.localStoragePrefix + "sources");
localStorage.removeItem(this.localStoragePrefix + "results");
+ localStorage.removeItem(this.localStoragePrefix + "claimsJob");
+ localStorage.removeItem(this.localStoragePrefix + "feedRecordsJob");
+
this._router.navigate(['/myclaims'], {queryParams: this.params});
}
}
@@ -517,8 +550,77 @@ export class ClaimInsertComponent {
}
if(this.defaultColors){
buttonClass+=" linksbaskettitles uk-padding-small ";
- }
+ }
return buttonClass + "uk-text-center ";
}
+
+ getStatus(){
+ if(this.feedRecordsJob && ! (this.feedRecordsJob.status == "COMPLETE" || this.feedRecordsJob.status == "ERROR") ) {
+ this.subscriptions.push(this.claimService.getStatus(this.feedRecordsJob.id, this.properties.claimsAPIURL).subscribe(data => {
+ console.log("feed", data);
+ this.feedRecordsJob = data.data;
+ if (this.feedRecordsJob.status == "COMPLETE" || data.data.status == "ERROR") {
+ this.insertedRecords = this.feedRecordsJob.insertedIds;
+ this.errorInRecords = this.feedRecordsJob.errorInClaims;
+ }
+ }, err => {
+ let error: ClaimsErrorMessage = new ClaimsErrorMessage();
+ error.type = "jobError";
+ this.createErrorMessagesPerEntity((this.insertedClaims.length == 0));
+ this.errors.push(error);
+ this.afterclaimsInsertion();
+ this.feedRecordsJob = null;
+ localStorage.removeItem(this.localStoragePrefix + "feedRecordsJob");
+ }
+
+ ));
+ }
+ if(this.claimsJob) {
+ this.subscriptions.push(this.claimService.getStatus(this.claimsJob.id, this.properties.claimsAPIURL).subscribe(data => {
+ console.log("claim", data);
+ this.claimsJob = data.data;
+ if ((this.claimsJob.status == "COMPLETE" || data.data.status == "ERROR") && ( !this.feedRecordsJob || !(this.feedRecordsJob.status == "COMPLETE" || data.data.status == "ERROR")) ) {
+ this.insertedClaims = this.claimsJob.insertedIds;
+ this.errorInClaims = this.claimsJob.errorInClaims;
+
+ if (this.claims2Insert != this.insertedClaims.length) {
+ let error: ClaimsErrorMessage = new ClaimsErrorMessage();
+ error.type = "claimServiceFail2Insert";
+ error.inserted = this.insertedClaims.length;
+ error.failed = this.errorInClaims.length;
+ this.createErrorMessagesPerEntity((this.insertedClaims.length == 0));
+ this.errors.push(error);
+ }
+ this.afterclaimsInsertion();
+
+
+ }
+ }, err => {
+ let error: ClaimsErrorMessage = new ClaimsErrorMessage();
+ error.type = "jobError";
+ this.createErrorMessagesPerEntity((this.insertedClaims.length == 0));
+ this.errors.push(error);
+ this.afterclaimsInsertion();
+ this.claimsJob = null;
+ localStorage.removeItem(this.localStoragePrefix + "claimsJob");
+
+ }
+ ));
+ }
+ }
+ saveLocalStorage(){
+ if (this.results != null) {
+ localStorage.setItem(this.localStoragePrefix + "results", JSON.stringify(this.results));
+ }
+ if (this.sources != null) {
+ localStorage.setItem(this.localStoragePrefix + "sources", JSON.stringify(this.sources));
+ }
+ if (this.claimsJob != null) {
+ localStorage.setItem(this.localStoragePrefix + "claimsJob", JSON.stringify(this.claimsJob));
+ }
+ if (this.feedRecordsJob != null) {
+ localStorage.setItem(this.localStoragePrefix + "feedRecordsJob", JSON.stringify(this.feedRecordsJob));
+ }
+ }
}
diff --git a/claims/linking/linkingGeneric.component.html b/claims/linking/linkingGeneric.component.html
index 9d0b1379..7f394dd2 100644
--- a/claims/linking/linkingGeneric.component.html
+++ b/claims/linking/linkingGeneric.component.html
@@ -45,7 +45,7 @@
-