add ordinal in Language Entity
This commit is contained in:
parent
bf07fed0f8
commit
2c914ead90
|
@ -37,6 +37,10 @@ public class LanguageEntity {
|
|||
private IsActive isActive;
|
||||
public static final String _isActive = "isActive";
|
||||
|
||||
@Column(name = "ordinal")
|
||||
private Integer ordinal;
|
||||
public static final String _ordinal = "ordinal";
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -84,4 +88,12 @@ public class LanguageEntity {
|
|||
public void setIsActive(IsActive isActive) {
|
||||
this.isActive = isActive;
|
||||
}
|
||||
|
||||
public Integer getOrdinal() {
|
||||
return ordinal;
|
||||
}
|
||||
|
||||
public void setOrdinal(Integer ordinal) {
|
||||
this.ordinal = ordinal;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,9 @@ public class Language {
|
|||
private IsActive isActive;
|
||||
public static final String _isActive = "isActive";
|
||||
|
||||
private Integer ordinal;
|
||||
public static final String _ordinal = "ordinal";
|
||||
|
||||
private String hash;
|
||||
public final static String _hash = "hash";
|
||||
|
||||
|
@ -76,6 +79,14 @@ public class Language {
|
|||
this.isActive = isActive;
|
||||
}
|
||||
|
||||
public Integer getOrdinal() {
|
||||
return ordinal;
|
||||
}
|
||||
|
||||
public void setOrdinal(Integer ordinal) {
|
||||
this.ordinal = ordinal;
|
||||
}
|
||||
|
||||
public String getHash() {
|
||||
return hash;
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ public class LanguageBuilder extends BaseBuilder<Language, LanguageEntity>{
|
|||
if (fields.hasField(this.asIndexer(Language._id))) m.setId(d.getId());
|
||||
if (fields.hasField(this.asIndexer(Language._code))) m.setCode(d.getCode());
|
||||
if (fields.hasField(this.asIndexer(Language._payload))) m.setPayload(d.getPayload());
|
||||
if (fields.hasField(this.asIndexer(Language._ordinal))) m.setOrdinal(d.getOrdinal());
|
||||
if (fields.hasField(this.asIndexer(Language._createdAt))) m.setCreatedAt(d.getCreatedAt());
|
||||
if (fields.hasField(this.asIndexer(Language._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
|
||||
if (fields.hasField(this.asIndexer(Language._isActive))) m.setIsActive(d.getIsActive());
|
||||
|
|
|
@ -18,6 +18,9 @@ public class LanguagePersist {
|
|||
|
||||
private String payload;
|
||||
|
||||
@NotNull(message = "{validation.empty}")
|
||||
private Integer ordinal;
|
||||
|
||||
private String hash;
|
||||
|
||||
public UUID getId() {
|
||||
|
@ -44,6 +47,14 @@ public class LanguagePersist {
|
|||
this.payload = payload;
|
||||
}
|
||||
|
||||
public Integer getOrdinal() {
|
||||
return ordinal;
|
||||
}
|
||||
|
||||
public void setOrdinal(Integer ordinal) {
|
||||
this.ordinal = ordinal;
|
||||
}
|
||||
|
||||
public String getHash() {
|
||||
return hash;
|
||||
}
|
||||
|
|
|
@ -161,6 +161,7 @@ public class LanguageQuery extends QueryBase<LanguageEntity> {
|
|||
item.setId(QueryBase.convertSafe(tuple, columns, LanguageEntity._id, UUID.class));
|
||||
item.setCode(QueryBase.convertSafe(tuple, columns, LanguageEntity._code, String.class));
|
||||
item.setPayload(QueryBase.convertSafe(tuple, columns, LanguageEntity._payload, String.class));
|
||||
item.setOrdinal(QueryBase.convertSafe(tuple, columns, LanguageEntity._ordinal, Integer.class));
|
||||
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, LanguageEntity._createdAt, Instant.class));
|
||||
item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, LanguageEntity._updatedAt, Instant.class));
|
||||
item.setIsActive(QueryBase.convertSafe(tuple, columns, LanguageEntity._isActive, IsActive.class));
|
||||
|
@ -172,6 +173,7 @@ public class LanguageQuery extends QueryBase<LanguageEntity> {
|
|||
if (item.match(Language._id)) return LanguageEntity._id;
|
||||
else if (item.match(Language._code)) return LanguageEntity._code;
|
||||
else if (item.match(Language._payload)) return LanguageEntity._payload;
|
||||
else if (item.match(Language._ordinal)) return LanguageEntity._ordinal;
|
||||
else if (item.match(Language._createdAt)) return LanguageEntity._createdAt;
|
||||
else if (item.match(Language._updatedAt)) return LanguageEntity._updatedAt;
|
||||
else if (item.match(Language._hash)) return LanguageEntity._updatedAt;
|
||||
|
|
|
@ -91,6 +91,7 @@ public class LanguageServiceImpl implements LanguageService {
|
|||
|
||||
data.setCode(model.getCode());
|
||||
data.setPayload(model.getPayload());
|
||||
data.setOrdinal(model.getOrdinal());
|
||||
data.setUpdatedAt(Instant.now());
|
||||
|
||||
if (isUpdate) this.entityManager.merge(data);
|
||||
|
|
|
@ -104,8 +104,8 @@ public class LanguageV2Controller {
|
|||
return model;
|
||||
}
|
||||
|
||||
@GetMapping("code/{code}")
|
||||
public Language get(@PathVariable("code") String code, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, IOException {
|
||||
@GetMapping("get-payload/{code}")
|
||||
public ResponseEntity getPayload(@PathVariable("code") String code, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, IOException {
|
||||
logger.debug(new MapLogEntry("retrieving" + Language.class.getSimpleName()).And("code", code).And("fields", fieldSet));
|
||||
|
||||
this.censorFactory.censor(LanguageCensor.class).censor(fieldSet, null);
|
||||
|
@ -124,7 +124,7 @@ public class LanguageV2Controller {
|
|||
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
|
||||
));
|
||||
|
||||
return model;
|
||||
return new ResponseEntity<>(model.getPayload().getBytes(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("available-languages")
|
||||
|
|
|
@ -3,6 +3,7 @@ import { BaseEntity, BaseEntityPersist } from "@common/base/base-entity.model";
|
|||
export interface Language extends BaseEntity{
|
||||
code: string;
|
||||
payload: string;
|
||||
ordinal: number;
|
||||
}
|
||||
|
||||
// Persist
|
||||
|
@ -10,4 +11,5 @@ export interface Language extends BaseEntity{
|
|||
export interface LanguagePersist extends BaseEntityPersist{
|
||||
code: string;
|
||||
payload: string;
|
||||
ordinal: number;
|
||||
}
|
|
@ -12,6 +12,7 @@ import { catchError, map } from 'rxjs/operators';
|
|||
import { nameof } from 'ts-simple-nameof';
|
||||
import { ConfigurationService } from '../configuration/configuration.service';
|
||||
import { BaseHttpV2Service } from '../http/base-http-v2.service';
|
||||
import { HttpResponse } from '@angular/common/http';
|
||||
|
||||
@Injectable()
|
||||
export class LanguageV2Service {
|
||||
|
@ -35,13 +36,11 @@ export class LanguageV2Service {
|
|||
catchError((error: any) => throwError(error)));
|
||||
}
|
||||
|
||||
getSingleWithCode(code: string, reqFields: string[] = []): Observable<Language> {
|
||||
const url = `${this.apiBase}/code/${code}`;
|
||||
const options = { params: { f: reqFields } };
|
||||
getPayload(code: string, reqFields: string[] = []): Observable<HttpResponse<Blob>> {
|
||||
const url = `${this.apiBase}/get-payload/${code}`;
|
||||
const options = { params: { f: reqFields }, responseType: 'blob', observe: 'response' };
|
||||
|
||||
return this.http
|
||||
.get<Language>(url, options).pipe(
|
||||
catchError((error: any) => throwError(error)));
|
||||
return this.http.get(url, options);
|
||||
}
|
||||
|
||||
queryAvailableCodes(q: LanguageLookup): Observable<QueryResult<string>> {
|
||||
|
|
|
@ -49,6 +49,14 @@
|
|||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'LANGUAGE-EDITOR.FIELDS.ORDINAL' | translate}}</mat-label>
|
||||
<input matInput type="text" name="ordinal" [formControl]="formGroup.get('ordinal')" required>
|
||||
<mat-error *ngIf="formGroup.get('ordinal').hasError('required')">
|
||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'LANGUAGE-EDITOR.FIELDS.PAYLOAD' | translate}}</mat-label>
|
||||
|
|
|
@ -107,13 +107,16 @@ export class LanguageEditorComponent extends BaseEditor<LanguageEditorModel, Lan
|
|||
prepareForm(data: Language) {
|
||||
try {
|
||||
if(data && data.payload == null){
|
||||
this.languageV2Service.getSingleWithCode(data.code, LanguageEditorResolver.lookupFields())
|
||||
this.languageV2Service.getPayload(data.code, LanguageEditorResolver.lookupFields())
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(language => {
|
||||
data.payload = language.payload;
|
||||
this.editorModel = data ? new LanguageEditorModel().fromModel(data) : new LanguageEditorModel();
|
||||
this.isDeleted = data ? data.isActive === IsActive.Inactive : false;
|
||||
this.buildForm();
|
||||
.subscribe(respone => {
|
||||
const blob = new Blob([respone.body], { type: 'text/html' });
|
||||
blob.text().then(text => {
|
||||
data.payload = text;
|
||||
this.editorModel = data ? new LanguageEditorModel().fromModel(data) : new LanguageEditorModel();
|
||||
this.isDeleted = data ? data.isActive === IsActive.Inactive : false;
|
||||
this.buildForm();
|
||||
});
|
||||
});
|
||||
}else{
|
||||
this.editorModel = data ? new LanguageEditorModel().fromModel(data) : new LanguageEditorModel();
|
||||
|
@ -198,10 +201,14 @@ export class LanguageEditorComponent extends BaseEditor<LanguageEditorModel, Lan
|
|||
}
|
||||
|
||||
public selectedCodeChanged(code: string){
|
||||
this.languageV2Service.getSingleWithCode(code, LanguageEditorResolver.lookupFields())
|
||||
this.languageV2Service.getPayload(code, LanguageEditorResolver.lookupFields())
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(language => {
|
||||
this.formGroup.get('payload').patchValue(language.payload);
|
||||
.subscribe(response => {
|
||||
const blob = new Blob([response.body], { type: 'text/html' });
|
||||
blob.text().then(text => {
|
||||
this.formGroup.get('payload').patchValue(text);
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import { Validation, ValidationContext } from "@common/forms/validation/validati
|
|||
export class LanguageEditorModel extends BaseEditorModel implements LanguagePersist {
|
||||
code: string;
|
||||
payload: string;
|
||||
ordinal: number;
|
||||
|
||||
permissions: string[];
|
||||
|
||||
|
@ -21,6 +22,7 @@ export class LanguageEditorModel extends BaseEditorModel implements LanguagePers
|
|||
super.fromModel(item);
|
||||
this.code = item.code;
|
||||
this.payload = item.payload;
|
||||
this.ordinal = item.ordinal;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
@ -31,7 +33,8 @@ export class LanguageEditorModel extends BaseEditorModel implements LanguagePers
|
|||
return this.formBuilder.group({
|
||||
id: [{ value: this.id, disabled: disabled }, context.getValidation('id').validators],
|
||||
code: [{ value: this.code, disabled: disabled }, context.getValidation('code').validators],
|
||||
payload: [{ value: this.payload, disabled: disabled }, context.getValidation('payload').validators],
|
||||
payload: [{ value: this.payload, disabled: disabled }, context.getValidation('payload').validators],
|
||||
ordinal: [{ value: this.ordinal, disabled: disabled }, context.getValidation('ordinal').validators],
|
||||
hash: [{ value: this.hash, disabled: disabled }, context.getValidation('hash').validators]
|
||||
});
|
||||
}
|
||||
|
@ -42,6 +45,7 @@ export class LanguageEditorModel extends BaseEditorModel implements LanguagePers
|
|||
baseValidationArray.push({ key: 'id', validators: [BackendErrorValidator(this.validationErrorModel, 'id')] });
|
||||
baseValidationArray.push({ key: 'code', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'code')] });
|
||||
baseValidationArray.push({ key: 'payload', validators: [BackendErrorValidator(this.validationErrorModel, 'payload')] });
|
||||
baseValidationArray.push({ key: 'ordinal', validators: [Validators.required, Validators.pattern("^[0-9]*$"), BackendErrorValidator(this.validationErrorModel, 'ordinal')] });
|
||||
baseValidationArray.push({ key: 'hash', validators: [] });
|
||||
|
||||
baseContext.validation = baseValidationArray;
|
||||
|
|
|
@ -21,6 +21,7 @@ export class LanguageEditorResolver extends BaseEditorResolver {
|
|||
nameof<Language>(x => x.id),
|
||||
nameof<Language>(x => x.code),
|
||||
nameof<Language>(x => x.payload),
|
||||
nameof<Language>(x => x.ordinal),
|
||||
nameof<Language>(x => x.createdAt),
|
||||
nameof<Language>(x => x.updatedAt),
|
||||
nameof<Language>(x => x.hash),
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
<form *ngIf="formGroup" (ngSubmit)="formSubmit()">
|
||||
<div>
|
||||
<mat-card class="col-md-8 offset-md-2">
|
||||
<mat-card-header>
|
||||
<mat-card-title>{{'SUPPORTIVE-MATERIAL-EDITOR.TITLE' | translate}}</mat-card-title>
|
||||
</mat-card-header>
|
||||
<div>
|
||||
<div class ="material">
|
||||
<mat-form-field>
|
||||
|
|
|
@ -1175,6 +1175,7 @@
|
|||
"UNSUCCESSFUL-DELETE": "This item could not be deleted."
|
||||
},
|
||||
"SUPPORTIVE-MATERIAL-EDITOR": {
|
||||
"TITLE": "Supportive Material",
|
||||
"FIELDS": {
|
||||
"MATERIAL-TYPE": "Material Type",
|
||||
"LANGUAGE": "Language"
|
||||
|
@ -1189,7 +1190,8 @@
|
|||
"NEW": "New Language",
|
||||
"FIELDS": {
|
||||
"CODE": "Code",
|
||||
"PAYLOAD": "Payload"
|
||||
"PAYLOAD": "Payload",
|
||||
"ORDINAL": "Ordinal"
|
||||
},
|
||||
"ACTIONS": {
|
||||
"SAVE": "Save",
|
||||
|
|
Loading…
Reference in New Issue