Skip to content

Commit

Permalink
strategy 1 added calling stored after every replace geneontology/noct…
Browse files Browse the repository at this point in the history
  • Loading branch information
tmushayahama committed Dec 31, 2020
1 parent 3926087 commit 87ca68e
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 47 deletions.
1 change: 0 additions & 1 deletion src/@noctua.form/models/annoton/cam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ export class Cam {
each(findEntities, (entity: Entity) => {
if (node.term.uuid === entity.uuid) {
node.term.termHistory.push(new Entity(node.term.id, node.term.label));

node.term.modified = true;
node.term.id = replaceWith.id;
node.term.label = replaceWith.label;
Expand Down
36 changes: 35 additions & 1 deletion src/@noctua.form/services/cams.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ import { Cam, CamQueryMatch, CamStats } from './../models/annoton/cam';
import { each, groupBy, find, remove } from 'lodash';
import { CamService } from './cam.service';
import { Entity } from './../models/annoton/entity';
import { HttpClient } from '@angular/common/http';
import { finalize } from 'rxjs/operators';
import { environment } from 'environments/environment';

@Injectable({
providedIn: 'root'
})
export class CamsService {

searchApi = environment.searchApi;
curieUtil: any;
loading = false;
cams: Cam[] = [];
Expand All @@ -32,6 +35,7 @@ export class CamsService {
public camFormGroup$: Observable<FormGroup>;

constructor(
private httpClient: HttpClient,
public noctuaFormConfigService: NoctuaFormConfigService,
private _noctuaGraphService: NoctuaGraphService,
private camService: CamService,
Expand Down Expand Up @@ -111,6 +115,21 @@ export class CamsService {
}
}

getStoredModel(id: string): Observable<any> {
const self = this;
const url = `${this.searchApi}/stored?id=${id}`;

self.loading = true;

return this.httpClient
.get(url)
.pipe(
//map(res => this.addCam(res)),
finalize(() => {
})
);
}

removeCamFromReview(cam: Cam) {
remove(this.cams, { id: cam.id });
this.updateDisplayNumber(this.cams);
Expand Down Expand Up @@ -142,6 +161,10 @@ export class CamsService {
});
}

applyStored() {

}

replace(entities: Entity[], replaceWithTerm: Entity) {
const self = this;
const groupedEntities = groupBy(entities, 'modelId') as { string: Entity[] };
Expand All @@ -166,6 +189,17 @@ export class CamsService {
return forkJoin(promises);
}

bulkStoredEdit() {
const self = this;
const promises = [];

each(this.cams, (cam: Cam) => {
promises.push(self.getStoredModel(cam.id));
});

return forkJoin(promises);
}

resetModels() {
const self = this;
const promises = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,6 @@ export class ArtBasketComponent implements OnInit, OnDestroy {
this.noctuaReviewSearchService.removeFromArtBasket(cam.id);
}

getStoredCam(cam: Cam) {
const searchCriteria = new SearchCriteria();

searchCriteria.ids = [cam.id];
this.noctuaReviewSearchService.getStoredModel(searchCriteria);
}

clear() {

const success = (cancel) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ export class ReviewFormComponent implements OnInit, OnDestroy {
if (replace) {
this.noctuaReviewSearchService.replaceAll(replaceWith).subscribe((cams) => {
if (cams) {
self.noctuaReviewSearchService.onReplaceChanged.next(true);
this.camsService.bulkStoredEdit().subscribe((cams) => {
self.noctuaReviewSearchService.onReplaceChanged.next(true);
});
}
});
}
Expand Down
32 changes: 2 additions & 30 deletions src/@noctua.search/services/noctua-review-search.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { environment } from './../../environments/environment';
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';

import { BehaviorSubject, Observable, Subject } from 'rxjs';
import { BehaviorSubject, Observable } from 'rxjs';
import { map, finalize } from 'rxjs/operators';

import {
Expand All @@ -17,20 +17,13 @@ import { each, find } from 'lodash';
import { CurieService } from '@noctua.curie/services/curie.service';
import { CamPage } from './../models/cam-page';
import { SearchHistory } from './../models/search-history';
import { NoctuaUtils } from '@noctua/utils/noctua-utils';
import { ArtBasket } from '@noctua.search/models/art-basket';
import { NoctuaSearchMenuService } from './search-menu.service';
import { NoctuaDataService } from '@noctua.common/services/noctua-data.service';

declare const require: any;

const amigo = require('amigo2');

@Injectable({
providedIn: 'root'
})
export class NoctuaReviewSearchService {
linker = new amigo.linker();
artBasket = new ArtBasket();
searchHistory: SearchHistory[] = [];
onSearchCriteriaChanged: BehaviorSubject<any>;
Expand All @@ -39,15 +32,13 @@ export class NoctuaReviewSearchService {
camPage: CamPage;
searchCriteria: SearchCriteria;
searchApi = environment.searchApi;
separator = '@@';
loading = false;
// onCamsChanged: BehaviorSubject<any>;
onArtBasketChanged: BehaviorSubject<any>;
onResetReview: BehaviorSubject<boolean>;
onReplaceChanged: BehaviorSubject<boolean>;
onCamsPageChanged: BehaviorSubject<any>;
onCamChanged: BehaviorSubject<any>;
searchSummary: any = {};
matchedEntities: Entity[] = [];
matchedCountCursor = 0;
matchedCount = 0;
Expand All @@ -60,7 +51,6 @@ export class NoctuaReviewSearchService {
};

constructor(
private noctuaDataService: NoctuaDataService,
public noctuaSearchMenuService: NoctuaSearchMenuService,
private httpClient: HttpClient,
private camsService: CamsService,
Expand All @@ -82,7 +72,7 @@ export class NoctuaReviewSearchService {
}

self.camsService.resetMatch();
this.getCams(searchCriteria).subscribe((response: any) => {
this.getCams(searchCriteria).subscribe(() => {
// this.cams = response;
this.matchedCountCursor = 0;
this.calculateMatched();
Expand Down Expand Up @@ -314,24 +304,6 @@ export class NoctuaReviewSearchService {
);
}

getStoredModel(searchCriteria: SearchCriteria): Observable<any> {
const self = this;
this.searchCriteria.expand = false;
const query = searchCriteria.build();
const url = `${this.searchApi}/stored?${query}`;

self.loading = true;

return this.httpClient
.get(url)
.pipe(
//map(res => this.addCam(res)),
finalize(() => {
self.loading = false;
})
);
}

addCam(res) {
const self = this;
const result: Array<Cam> = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,6 @@ export class CamsReviewComponent implements OnInit, OnDestroy {
this.camService.loadCam(cam);
}

getStoredCam(cam: Cam) {
const searchCriteria = new SearchCriteria();

searchCriteria.ids = [cam.id];
this.noctuaReviewSearchService.getStoredModel(searchCriteria);
}

selectMiddlePanel(panel) {
this.noctuaSearchMenuService.selectMiddlePanel(panel);

Expand Down

0 comments on commit 87ca68e

Please sign in to comment.