Skip to content

Commit

Permalink
Merge pull request #196 from geneontology/model-copy
Browse files Browse the repository at this point in the history
Added raw copy requests without using bbop manager
  • Loading branch information
tmushayahama authored Jul 5, 2022
2 parents 4a6481f + 6cab5d6 commit a8dd62f
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/@noctua.form/services/cam.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ export class CamService {
copyModel(cam: Cam, title) {
const self = this;

return self._noctuaGraphService.copyModel(cam, title).then((response) => {
const cam: Cam = self._noctuaGraphService.getMetadata(response.data())
return self._noctuaGraphService.copyModelRaw(cam, title).subscribe((response) => {
const cam: Cam = self._noctuaGraphService.getMetadata(response['data'])
self.onCopyModelChanged.next(cam)
});
}
Expand Down
68 changes: 67 additions & 1 deletion src/@noctua.form/services/graph.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { TermsSummary } from './../models/activity/summary';
import { Article } from './../models/article';
import { Contributor, equalContributor } from '../models/contributor';
import * as moment from 'moment';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';

declare const require: any;

Expand Down Expand Up @@ -901,6 +901,72 @@ export class NoctuaGraphService {
return cam.copyModelManager.request_with(reqs);
}

copyModelRaw(cam: Cam, title) {
const self = this;
const baristaUrl = environment.globalBaristaLocation
const globalMinervaDefinitionName = environment.globalMinervaDefinitionName

let headers = new HttpHeaders();
headers = headers.append('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');

const requests = [
{
"entity": "model",
"operation": "copy",
"arguments":
{
"model-id": cam.id,
"values": [
{
"key": "title",
"value": title
}]
}
}]
let payload = `token=${this.noctuaUserService.baristaToken}&intention=query&requests=${encodeURIComponent(JSON.stringify(requests))}`

if (self.noctuaUserService.user && self.noctuaUserService.user.groups.length > 0) {
payload = payload + '&provided-by=' + self.noctuaUserService.user.group.id;
}
return this.httpClient.post(`${baristaUrl}/api/${globalMinervaDefinitionName}/m3BatchPrivileged`, payload, { headers });
}

copyModelRaw2(cam: Cam, title) {
const self = this;
const baristaUrl = environment.globalBaristaLocation
const globalMinervaDefinitionName = environment.globalMinervaDefinitionName

let headers = new HttpHeaders();
headers = headers.append('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');

const requests = [
{
"entity": "model",
"operation": "copy",
"arguments":
{
"model-id": cam.id,
"title": title
}
}]

const requestParams = {
token: this.noctuaUserService.baristaToken,
intention: 'query',
//requests: requests
}

if (self.noctuaUserService.user && self.noctuaUserService.user.groups.length > 0) {
// requestParams['provided-by'] = self.noctuaUserService.user.group.id
}

const params = new HttpParams({
fromObject: requestParams
});
const payload = params.toString();
return this.httpClient.post(`${baristaUrl}/api/${globalMinervaDefinitionName}/m3BatchPrivileged`, payload, { headers });
}

resetModel(cam: Cam) {
const self = this;
const reqs = new minerva_requests.request_set(self.noctuaUserService.baristaToken, cam.id);
Expand Down
2 changes: 1 addition & 1 deletion workbenches/noctua-form/public/inject.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,6 @@
</div>
</noctua-splash-screen>
<noctua-root></noctua-root>
<script src="runtime.38b1f495cb4cd82a.js" type="module"></script><script src="polyfills.a39db01cea6f891e.js" type="module"></script><script src="scripts.79b3808e7d5e20c8.js" defer></script><script src="main.8621a01ec82081f0.js" type="module"></script>
<script src="runtime.38b1f495cb4cd82a.js" type="module"></script><script src="polyfills.a39db01cea6f891e.js" type="module"></script><script src="scripts.79b3808e7d5e20c8.js" defer></script><script src="main.4b0fbfff51d0e272.js" type="module"></script>

</body></html>

Large diffs are not rendered by default.

0 comments on commit a8dd62f

Please sign in to comment.