import { FormGroup, FormBuilder } from '@angular/forms';
import { isNullOrUndefined } from 'util';

export class DatasetIdModel {
	identifier: string;
	type: string;

	constructor(data: any) {
		const parsed = JSON.parse(data);
		if (!isNullOrUndefined(parsed)) {
			this.identifier = parsed.identifier;
			this.type = parsed.type;
		}
	}

	buildForm(): FormGroup {
		return new FormBuilder().group({
			identifier: [this.identifier],
			type: [this.type]
		});
	}
}
