Skip to content

Commit

Permalink
added the connection and its data models model form
Browse files Browse the repository at this point in the history
  • Loading branch information
tmushayahama committed Feb 26, 2019
1 parent 17c304b commit 87ad1d2
Show file tree
Hide file tree
Showing 20 changed files with 247 additions and 417 deletions.
3 changes: 3 additions & 0 deletions src/@noctua.form/models/annoton/annoton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import { AnnotonError } from "./parser/annoton-error.js";
import { AnnotonNode } from './annoton-node'

export class Annoton extends SaeGraph {
gp;
annotonPresentation;
annotonRows;
nodes;
annotonType;
annotonModelType;
Expand Down
8 changes: 8 additions & 0 deletions src/@noctua.form/models/annoton/cam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ export class Cam {
this._annotons = annoton;
}

getAnnotonByConnectionId(connectionId) {
const self = this;
let result = _.find(self._annotons, (annoton: Annoton) => {
return annoton.connectionId === connectionId;
})

return result;
}

getMFNodes() {
const self = this;
Expand Down
25 changes: 24 additions & 1 deletion src/@noctua.form/services/annoton-connector.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import { FormGroup, FormControl, FormBuilder, FormArray, Validators } from '@ang
import { noctuaFormConfig } from './../noctua-form-config';
import { NoctuaFormConfigService } from './config/noctua-form-config.service';
import { NoctuaLookupService } from './lookup.service';
import { CamService } from '@noctua.form/services/cam.service';

import * as _ from 'lodash';
declare const require: any;
const each = require('lodash/forEach');

import { Cam } from '@noctua.form/models/annoton/cam';
import { Annoton } from '@noctua.form/models/annoton/annoton';
import { AnnotonNode } from '@noctua.form/models/annoton/annoton-node';

Expand All @@ -24,26 +26,37 @@ import { CamFormMetadata } from './../models/forms/cam-form-metadata';
providedIn: 'root'
})
export class NoctuaAnnotonConnectorService {
cam: Cam;
public annoton: Annoton;
public subjectMFNode: AnnotonNode;
public objectMFNode: AnnotonNode;
public annotonPresentation;
private connectorForm: AnnotonConnectorForm;
private connectorFormGroup: BehaviorSubject<FormGroup | undefined>;
public connectorFormGroup$: Observable<FormGroup>;

constructor(private _fb: FormBuilder, private noctuaFormConfigService: NoctuaFormConfigService,
private camService: CamService,
private noctuaLookupService: NoctuaLookupService) {

this.annoton = this.noctuaFormConfigService.createAnnotonConnectorModel();
this.connectorFormGroup = new BehaviorSubject(null);
this.connectorFormGroup$ = this.connectorFormGroup.asObservable()

this.camService.onCamChanged.subscribe((cam) => {
this.cam = cam;
});

this.initalizeForm();
}

initalizeForm(annoton?: Annoton) {
if (annoton) {
this.annoton = annoton;
}

this.subjectMFNode = this.annoton.getNode('mf');
this.objectMFNode = this.annoton.getNode('mf-1');
this.connectorForm = this.createConnectorForm()
this.connectorFormGroup.next(this._fb.group(this.connectorForm));
}
Expand All @@ -58,6 +71,17 @@ export class NoctuaAnnotonConnectorService {
return connectorForm;
}

createConnection(subjectId, objectId, edge?) {
let subjectAnnoton: Annoton = this.cam.getAnnotonByConnectionId(subjectId);
let objectAnnoton: Annoton = this.cam.getAnnotonByConnectionId(objectId);

let subjectMFNode = subjectAnnoton.getMFNode();
let objectMFNode = objectAnnoton.getMFNode();
let annoton = this.noctuaFormConfigService.createAnnotonConnectorModel(subjectMFNode, objectMFNode, edge);

this.initalizeForm(annoton);
}

connectorFormToAnnoton(annoton: Annoton, connectorForm) {
const self = this;

Expand All @@ -66,7 +90,6 @@ export class NoctuaAnnotonConnectorService {
console.dir(annoton)
}


clearForm() {
this.annoton = this.noctuaFormConfigService.createAnnotonModel(
this.annoton.annotonType,
Expand Down
3 changes: 3 additions & 0 deletions src/@noctua.form/services/cam.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class CamService {
baseUrl = environment.spaqrlApiUrl;
curieUtil: any;
loading: boolean = false;
cam: Cam;
onCamsChanged: BehaviorSubject<any>;
onCamChanged: BehaviorSubject<any>;

Expand Down Expand Up @@ -58,7 +59,9 @@ export class CamService {
});
cam.expanded = true;
this.noctuaGraphService.getGraphInfo(cam, modelId);
this.cam = cam;
this.onCamChanged.next(cam);

return cam;
}

Expand Down
23 changes: 20 additions & 3 deletions src/@noctua.form/services/config/noctua-form-config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -919,12 +919,12 @@ export class NoctuaFormConfigService {

}

createAnnotonConnectorModel() {
createAnnotonConnectorModel(srcSubjectMFNode?: AnnotonNode, srcObjectMFNode?: AnnotonNode, edge?: any) {
const self = this;
let annoton = new Annoton();
let modelIds = _.cloneDeep(self._modelRelationship);
let subjectMFNode = self.generateNode('mf');
let objectMFNode = self.generateNode('mf', { id: '-1' });
let subjectMFNode: AnnotonNode;
let objectMFNode: AnnotonNode;
let edgeOption = {
selected: noctuaFormConfig.edge.upstreamOfOrWithin,
options: [
Expand All @@ -937,11 +937,28 @@ export class NoctuaFormConfigService {
]
};

if (srcSubjectMFNode) {
subjectMFNode = srcSubjectMFNode;
} else {
subjectMFNode = self.generateNode('mf');
}

if (srcObjectMFNode) {
objectMFNode = srcObjectMFNode;
} else {
objectMFNode = self.generateNode('mf', { id: '-1' });
}

annoton.addNode(subjectMFNode);
annoton.addNode(objectMFNode);
subjectMFNode.addEdgeOption(edgeOption);
// annoton.addEdge(subjectMFNode, objectMFNode, annoton.edgeOption.selected);

if (edge) {
edgeOption.selected = edge;
annoton.addEdge(subjectMFNode, objectMFNode, edgeOption.selected);
}

return annoton;
}

Expand Down
26 changes: 9 additions & 17 deletions src/@noctua.form/services/graph.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export class NoctuaGraphService {

self.graphPreParse(cam.graph).subscribe((data) => {
cam.annotons = self.graphToAnnotons(cam.graph);
cam.annotons = [...self.annotonsToTable(cam.graph, cam.annotons), ...self.ccComponentsToTable(cam.graph, data)]
self.annotonsToTable(cam.graph, cam.annotons)
cam.onGraphChanged.next(cam.annotons);
})

Expand Down Expand Up @@ -662,33 +662,25 @@ export class NoctuaGraphService {
});
}

annotonsToTable(graph, annotons) {
annotonsToTable(graph, annotons: Annoton[]) {
const self = this;
let result = [];
// let result = [];

each(annotons, function (annoton) {
let annotonRows = self.annotonToTableRows(graph, annoton);
annoton.annotonRows = self.annotonToTableRows(graph, annoton);

result = result.concat(annotonRows);
// result = result.concat(annotonRows);
});

return result;
// return result;
}

annotonToTableRows(graph, annoton) {
annotonToTableRows(graph, annoton: Annoton) {
const self = this;
let result = [];

let gpNode = annoton.getGPNode();

let row = {
gp: gpNode.term.control.value.label,
original: JSON.parse(JSON.stringify(annoton)),
annoton: annoton,
annotonPresentation: self.formGridService.getAnnotonPresentation(annoton),
}

return row;
//annoton.gpTerm = gpNode.term.control.value.label;
annoton.annotonPresentation = self.formGridService.getAnnotonPresentation(annoton);
}

ccComponentsToTable(graph, annotons) {
Expand Down
Loading

0 comments on commit 87ad1d2

Please sign in to comment.