Skip to content

Commit

Permalink
Merge pull request #75 from AMOSTeam1/templ2
Browse files Browse the repository at this point in the history
Beatification
  • Loading branch information
jmnietsch authored Jul 10, 2018
2 parents e0adddd + d0b4f71 commit ac61d94
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,24 @@ public class NfaCatalog implements NfaInterface{
public static class BlueprintConverter implements AttributeConverter<NfaCatalogBlueprint, String> {
@Override
public String convertToDatabaseColumn(NfaCatalogBlueprint attribute) {

if (attribute == null) {
return null;
}

try (StringWriter stringWriter = new StringWriter()) {
new ObjectMapper().writeValue(stringWriter, attribute);
return stringWriter.toString();
} catch (IOException e) {
throw new IllegalStateException("Obj-to-JSON-Converting failed", e);
}

}

@Override
public NfaCatalogBlueprint convertToEntityAttribute(String dbData) {
try {
return dbData == null ? null
: new ObjectMapper().readValue(dbData, NfaCatalogBlueprint.class);
return dbData == null ? null : new ObjectMapper().readValue(dbData, NfaCatalogBlueprint.class);
} catch (IOException e) {
throw new IllegalStateException("JSON-to-Obj-Converting failed", e);
}
Expand Down Expand Up @@ -121,11 +120,11 @@ public void setEn(BpPropertyTemplateNoCondition en) {
public void createDescription(List<String> wert) {
if (de.getErklaerung() == null) {
de.setErklaerung(String.join(" ", de.getCharacteristic(), de.getProperty(), de.getModalVerb(),
de.getQualifiedValue(wert), de.getVerb()));
de.getQualifiedValue(wert), de.getVerb()) + ".");
}
if (en.getErklaerung() == null) {
en.setErklaerung(String.join(" ", en.getCharacteristic(), en.getProperty(), en.getModalVerb(),
en.getVerb(), en.getQualifiedValue(wert)));
en.getVerb(), en.getQualifiedValue(wert)) + ".");
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions nfafrontend/src/app/newnfa/newnfa.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
<label for="nfa_type" class="control-label col-xs-2"><p>{{ 'nfa.type' | translate }}</p></label>
<div class="col-xs-3">
<select class="form-control" formControlName ="nfa_type" id="nfa_type" name="nfa_type" required [(ngModel)]='selectedType'>
<option value="nfa_type_1">Eigenschaftsschablone</option>
<option value="nfa_type_2">Eigenschaftsschablone mit Bedingung</option> <!--TODO generalize option with bilingual value-->
<option value="nfa_type_1">Eigenschaftsschablone</option> <!--TODO make bilingual-->
<!--<option value="nfa_type_2">Eigenschaftsschablone mit Bedingung</option>--> <!--Removed since there is no function in yet.-->
</select> <br>
</div>
</div>
Expand All @@ -47,7 +47,8 @@
<app-nfatemplate *ngIf="nfaform.get('nfa_type').value==='nfa_type_1'" [validUpdate]="validUpdate"></app-nfatemplate>

<br><br>
<button class="btn btn-primary pull-right addnfa" type="submit" [disabled]="!valid">NFA hinzufügen</button>
<label>{{lastNfaNumber() ? ('nfa.newNfaMessage' | translate:{'number': lastNfaNumber()}) : '' }}</label>
<button class="btn btn-primary pull-right addnfa" type="submit" [disabled]="!valid">NFA hinzufügen</button><!--TODO make bilingual-->
<br>
</form>
<br><br>
Expand Down
35 changes: 22 additions & 13 deletions nfafrontend/src/app/newnfa/newnfa.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {FormControl, FormGroup, Validators} from '@angular/forms';
import {AfterViewInit, Component, OnDestroy, OnInit, ViewChild} from '@angular/core';
import {FormControl, FormGroup, Validators} from '@angular/forms';
import {DataStorageService} from '../shared/data-storage.service';

import {NfacatalogService} from '../nfacatalog/nfacatalog.service';
Expand All @@ -12,7 +12,6 @@ import {BpPropertyTemplateNoCondition} from '../shared/blueprints/bpPropertyTemp
import {NfaCatalogModel} from '../shared/nfaCatalog.model';
import {QualifiyingExpression} from '../shared/blueprints/QualifiyingExpression.model';
import {ISubscription} from "rxjs/Subscription";
import {TranslateService} from "@ngx-translate/core";


@Component({
Expand All @@ -23,11 +22,12 @@ import {TranslateService} from "@ngx-translate/core";
export class NewnfaComponent implements OnInit, AfterViewInit, OnDestroy {

constructor(private dataStorageService: DataStorageService,
private nfaCatalogService: NfacatalogService,
private translateService: TranslateService) {
private nfaCatalogService: NfacatalogService)
{
this.subscription = [];
}

private createdNfaNumber: string = null;
nfaform: FormGroup;
nfaFactors: NfaFactorModel[];
@ViewChild(NfatemplateComponent) nfatemplate;
Expand All @@ -40,6 +40,7 @@ export class NewnfaComponent implements OnInit, AfterViewInit, OnDestroy {

validUpdate = (value: boolean) => {
this.valid = value;
this.createdNfaNumber = null;
};

private subscription: ISubscription[];
Expand Down Expand Up @@ -113,15 +114,19 @@ export class NewnfaComponent implements OnInit, AfterViewInit, OnDestroy {
null
);

this.dataStorageService.storeNfa(this.selectedMetric.id, nfaCatalogModel)
.subscribe(
response => {
console.log(response);
},
error1 => {
console.log(error1);
}
);
this.dataStorageService.storeNfa(this.selectedMetric.id, nfaCatalogModel)
.subscribe(
response => {
this.createdNfaNumber = this.selectedFactor.factorNumber +
'.' + this.selectedCriteria.criteriaNumber +
'.' + this.selectedMetric.metricNumber +
'.' + response.nfaNumber;
console.log(response);
},
error1 => {
console.log(error1);
}
);
}

factorHasCriteria() {
Expand All @@ -135,4 +140,8 @@ export class NewnfaComponent implements OnInit, AfterViewInit, OnDestroy {
&& this.selectedCriteria.metricList != null
&& this.selectedCriteria.metricList.length > 0);
}

lastNfaNumber() {
return this.createdNfaNumber;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
import {Component, EventEmitter, OnDestroy, OnInit, Output} from '@angular/core';
import {FormArray, FormControl, FormGroup, Validators} from '@angular/forms';
import {DataexchangeService} from '../../../shared/dataexchange.service';
import {Inst} from '../../../shared/blueprints/inst.model';
Expand All @@ -10,12 +10,11 @@ import {isNull} from 'util';
templateUrl: './denfaform.component.html',
styleUrls: ['./denfaform.component.css']
})
export class DenfaformComponent implements OnInit {
export class DenfaformComponent implements OnInit, OnDestroy {
deForm: FormGroup;
@Input() send = false;
@Output() submitEvent = new EventEmitter<FormGroup>();

modalVerbDe: Array<string> = ['muss', 'muessen', 'soll', 'sollen', 'kann', 'koennen'];
modalVerbDe: Array<string> = ['muss', 'müssen', 'soll', 'sollen', 'kann', 'können'];
qualExpr: Array<QualifiyingExpression> = QualifiyingExpression.listContent();

constructor(
Expand Down Expand Up @@ -71,6 +70,10 @@ export class DenfaformComponent implements OnInit {
}
}

ngOnDestroy() {
this.data.changeMessage(new Inst(null, null, null));
}

resetForm() {
if ((<FormArray>this.deForm.get('valueInput')).length === 2) {
(<FormArray>this.deForm.get('valueInput')).removeAt(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<div class="form-group" >
<label for="modalVerbInput" class="control-label col-xs-6">Requirement level</label>
<div class="col-xs-6">
<input readonly type="text" class="form-control" id="modalVerbInput" name="modalVerbInput" formControlName="modalVerb">
<input readonly type="text" class="form-control" id="modalVerbInput" name="modalVerb" formControlName="modalVerb">
</div>
</div>
<div class="form-group" >
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,36 @@
import {Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChange, SimpleChanges} from '@angular/core';
import {
AfterViewInit,
Component,
EventEmitter,
Input,
OnChanges,
OnDestroy,
OnInit,
Output,
SimpleChange,
SimpleChanges
} from '@angular/core';
import {FormArray, FormControl, FormGroup, Validators} from '@angular/forms';
import {DataexchangeService} from '../../../shared/dataexchange.service';
import {until} from 'selenium-webdriver';
import elementIsSelected = until.elementIsSelected;
import {isNull, isNumber} from 'util';
import {QualifiyingExpression} from '../../../shared/blueprints/QualifiyingExpression.model';
import {ISubscription} from 'rxjs/Subscription';
import {Inst} from '../../../shared/blueprints/inst.model';

@Component({
selector: 'app-ennfaform',
templateUrl: './ennfaform.component.html',
styleUrls: ['./ennfaform.component.css']
})
export class EnnfaformComponent implements OnInit {
export class EnnfaformComponent implements OnInit, OnDestroy {
checked = false;
@Input() send = false;
@Output() submitEvent = new EventEmitter<FormGroup>();
enForm: FormGroup;
subscription: ISubscription;


constructor(private data: DataexchangeService) { }
constructor(private data: DataexchangeService) {}

ngOnInit() {
this.enForm = new FormGroup({
Expand All @@ -30,14 +42,14 @@ export class EnnfaformComponent implements OnInit {
'valueInput': new FormArray([new FormControl(null)]),
'verb': new FormControl('be')
});
this.data.currentMessage.subscribe(message => {
if ((message.verb === 'muessen') || (message.verb === 'muss')) {
this.subscription = this.data.currentMessage.subscribe(message => {
if ((message.verb === 'müssen') || (message.verb === 'muss')) {
this.enForm.get('modalVerb').reset('shall');
}
if ((message.verb === 'sollen') || (message.verb === 'soll')) {
this.enForm.get('modalVerb').reset('should');
}
if ((message.verb === 'koennen') || (message.verb === 'kann')) {
if ((message.verb === 'können') || (message.verb === 'kann')) {
this.enForm.get('modalVerb').reset('can');
}
if (message.verb === null) {
Expand All @@ -58,16 +70,19 @@ export class EnnfaformComponent implements OnInit {
fa.setControl(1, new FormControl(message.wert[1]));
} else if ((!isNull(message.qualifExp)) && (isNull(message.qualifExp.abundant)) && (fa.length === 2)) {
fa.removeAt(1);
}
}
});
}

ngOnDestroy() {
this.subscription.unsubscribe();
}

resetForm() {
if ((<FormArray>this.enForm.get('valueInput')).length === 2) {
(<FormArray>this.enForm.get('valueInput')).removeAt(1);
}
this.enForm.reset();
this.enForm.get('verb').reset('be');
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<div class="col-xs-5"></div>
<div class="bptdiv col-xs-1">
<span class="bpt">muss</span>
<span class="bpt">muessen</span>
<span class="bpt">müssen</span>
<span class="bpt">soll</span>
</div>
<div class="col-xs-6"></div>
Expand Down Expand Up @@ -57,7 +57,6 @@
</ng-template>
</div>

<!--end qula-->
<div class="col-xs-2">
<div *ngIf="deComponent.deForm.get('chbox').value; else valueDE">
<div *ngIf="(deComponent.deForm.get('valueInput')).length===2; else onlyValueInp">
Expand All @@ -72,7 +71,7 @@
</ng-template>
</div>

<div class="col-xs-2"><span class="bpt" *ngIf="hasValue(deComponent.deForm.get('verb')); else verbenDE">{{deComponent.deForm.get('verb').value}}</span>
<div class="col-xs-2"><span class="bpt" *ngIf="hasValue(deComponent.deForm.get('verb')); else verbenDE">{{deComponent.deForm.get('verb').value + '.'}}</span>
<ng-template #verbenDE>
<span class="bpt">sein / betragen</span>
</ng-template>
Expand All @@ -82,7 +81,7 @@
<div class="col-xs-5"></div>
<div class="col-xs-1 bptdiv">
<span class="bpt">kann</span>
<span class="bpt">koennen</span></div>
<span class="bpt">können</span></div>
<div class="col-xs-6"></div>
</div>
<br>
Expand Down Expand Up @@ -136,14 +135,14 @@
<div *ngIf="deComponent.deForm.get('chbox').value; else valueEN">
<div *ngIf="(deComponent.deForm.get('valueInput')).length===2; else onlyValueInp">
<div class="bpt">{{getValue(0)}}</div>
<div class="bpt">{{getValue(1)}}</div>
<div class="bpt">{{getValue(1) ? getValue(1) + '.' : ''}}</div>
</div>
<ng-template #onlyValueInp>
<span class="bpt">{{getValue(0)}}</span>
<span class="bpt">{{getValue(0) ? getValue(0) + '.' : ''}}</span>
</ng-template>
</div>
<ng-template #valueEN>
<span class="bpt">Value</span>
<span class="bpt">Value.</span>
</ng-template>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class QualifiyingExpression {
public static listContent(): Array<QualifiyingExpression> {

return [
new QualifiyingExpression('gleich', 'equals', null ),
new QualifiyingExpression('gleich', 'equal', null ),
new QualifiyingExpression('genau', 'exactly', null ),
new QualifiyingExpression('größer als', 'greater than', null ),
new QualifiyingExpression('mehr als', 'more than', null ),
Expand Down
8 changes: 1 addition & 7 deletions nfafrontend/src/app/shared/dataexchange.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,14 @@ export class DataexchangeService {
static currProject : string = 'currProject';
static project_mode : string = 'project_mode';

private messageSource = new BehaviorSubject(new Inst(null, null, null));
private messageSource = new BehaviorSubject<Inst>(new Inst(null, null, null));
currentMessage = this.messageSource.asObservable();

constructor() { }

changeMessage(message: Inst) {
this.messageSource.next(message);
}


/* (message: string) {
this.messageSource.next(message);
}*/

}


3 changes: 2 additions & 1 deletion nfafrontend/src/assets/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
"save" : "Speichern",
"edit" : "Bearbeiten",
"back" : "Zurück",
"none" : "Keine"
"none" : "Keine",
"newNfaMessage": "NFA mit der Nummer {{number}} wurde angelegt"
}
}
3 changes: 2 additions & 1 deletion nfafrontend/src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
"save" : "Save",
"edit" : "Edit",
"back" : "Back",
"none" : "None"
"none" : "None",
"newNfaMessage": "NFA with the number {{number}} was created"
}
}

0 comments on commit ac61d94

Please sign in to comment.