import { Injectable, ɵɵdefineInjectable, ɵɵinject, Component, Input, ViewChild, ViewEncapsulation, NgModule } from '@angular/core';
import { HttpHeaders, HttpClient, HttpClientModule } from '@angular/common/http';
import { of } from 'rxjs';
import { catchError, map } from 'rxjs/operators';
import { messageType, MessageService } from 'ui-message-angular';
import { FormGroup, FormBuilder, FormControl, Validators, FormsModule, ReactiveFormsModule } from '@angular/forms';
import { CommonModule } from '@angular/common';

/**
 * @fileoverview added by tsickle
 * Generated from: lib/entity.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
class Entity {
}
if (false) {
    /** @type {?} */
    Entity.prototype.ENTITY_ID;
    /** @type {?} */
    Entity.prototype.INSTANCE_GUID;
    /** @type {?} */
    Entity.prototype.relationships;
    /* Skipping unhandled member: [key: string]: any;*/
}
class Relationship {
}
if (false) {
    /** @type {?} */
    Relationship.prototype.RELATIONSHIP_ID;
    /** @type {?} */
    Relationship.prototype.SELF_ROLE_ID;
    /** @type {?} */
    Relationship.prototype.values;
}
class RelationshipInstance {
}
if (false) {
    /** @type {?} */
    RelationshipInstance.prototype.action;
    /** @type {?} */
    RelationshipInstance.prototype.RELATIONSHIP_INSTANCE_GUID;
    /** @type {?} */
    RelationshipInstance.prototype.VALID_FROM;
    /** @type {?} */
    RelationshipInstance.prototype.VALID_TO;
    /** @type {?} */
    RelationshipInstance.prototype.PARTNER_INSTANCES;
    /* Skipping unhandled member: [key: string]: any;*/
}
class PartnerInstance {
}
if (false) {
    /** @type {?} */
    PartnerInstance.prototype.ENTITY_ID;
    /** @type {?} */
    PartnerInstance.prototype.ROLE_ID;
    /** @type {?} */
    PartnerInstance.prototype.INSTANCE_GUID;
    /* Skipping unhandled member: [key: string]: any;*/
}
class PartnerRole {
}
if (false) {
    /** @type {?} */
    PartnerRole.prototype.ENTITY_ID;
    /** @type {?} */
    PartnerRole.prototype.ROLE_ID;
}
class EntityMeta {
}
if (false) {
    /** @type {?} */
    EntityMeta.prototype.ENTITY_ID;
    /** @type {?} */
    EntityMeta.prototype.ENTITY_DESC;
    /** @type {?} */
    EntityMeta.prototype.VERSION_NO;
    /** @type {?} */
    EntityMeta.prototype.ROLES;
}
class Attribute {
}
if (false) {
    /** @type {?} */
    Attribute.prototype.ATTR_GUID;
    /** @type {?} */
    Attribute.prototype.RELATION_ID;
    /** @type {?} */
    Attribute.prototype.ATTR_NAME;
    /** @type {?} */
    Attribute.prototype.ATTR_DESC;
    /** @type {?} */
    Attribute.prototype.DATA_ELEMENT;
    /** @type {?} */
    Attribute.prototype.SEARCH_HELP_ID;
    /** @type {?} */
    Attribute.prototype.SEARCH_HELP_EXPORT_FIELD;
    /** @type {?} */
    Attribute.prototype.DOMAIN_ID;
    /** @type {?} */
    Attribute.prototype.DOMAIN_TYPE;
    /** @type {?} */
    Attribute.prototype.REG_EXPR;
    /** @type {?} */
    Attribute.prototype.DOMAIN_ENTITY_ID;
    /** @type {?} */
    Attribute.prototype.DOMAIN_RELATION_ID;
    /** @type {?} */
    Attribute.prototype.LABEL_TEXT;
    /** @type {?} */
    Attribute.prototype.LIST_HEADER_TEXT;
    /** @type {?} */
    Attribute.prototype.DATA_TYPE;
    /** @type {?} */
    Attribute.prototype.DATA_LENGTH;
    /** @type {?} */
    Attribute.prototype.DECIMAL;
    /** @type {?} */
    Attribute.prototype.CAPITAL_ONLY;
    /** @type {?} */
    Attribute.prototype.UNSIGNED;
    /** @type {?} */
    Attribute.prototype.ORDER;
    /** @type {?} */
    Attribute.prototype.PRIMARY_KEY;
    /** @type {?} */
    Attribute.prototype.AUTO_INCREMENT;
}
class Role {
}
if (false) {
    /** @type {?} */
    Role.prototype.ROLE_ID;
    /** @type {?} */
    Role.prototype.ROLE_DESC;
    /** @type {?} */
    Role.prototype.CONDITIONAL_ATTR;
    /** @type {?} */
    Role.prototype.CONDITIONAL_VALUE;
    /** @type {?} */
    Role.prototype.RELATIONS;
    /** @type {?} */
    Role.prototype.RELATIONSHIPS;
}
class RoleRelation {
}
if (false) {
    /** @type {?} */
    RoleRelation.prototype.RELATION_ID;
    /** @type {?} */
    RoleRelation.prototype.RELATION_DESC;
    /** @type {?} */
    RoleRelation.prototype.CARDINALITY;
}
class RelationshipMeta {
}
if (false) {
    /** @type {?} */
    RelationshipMeta.prototype.RELATIONSHIP_ID;
    /** @type {?} */
    RelationshipMeta.prototype.RELATIONSHIP_DESC;
    /** @type {?} */
    RelationshipMeta.prototype.VALID_PERIOD;
    /** @type {?} */
    RelationshipMeta.prototype.SINGLETON;
    /** @type {?} */
    RelationshipMeta.prototype.CREATE_BY;
    /** @type {?} */
    RelationshipMeta.prototype.CREATE_TIME;
    /** @type {?} */
    RelationshipMeta.prototype.LAST_CHANGE_BY;
    /** @type {?} */
    RelationshipMeta.prototype.LAST_CHANGE_TIME;
    /** @type {?} */
    RelationshipMeta.prototype.INVOLVES;
}
class Involve {
}
if (false) {
    /** @type {?} */
    Involve.prototype.ROLE_ID;
    /** @type {?} */
    Involve.prototype.ROLE_DESC;
    /** @type {?} */
    Involve.prototype.CARDINALITY;
    /** @type {?} */
    Involve.prototype.DIRECTION;
}
class RelationMeta {
}
if (false) {
    /** @type {?} */
    RelationMeta.prototype.RELATION_ID;
    /** @type {?} */
    RelationMeta.prototype.RELATION_DESC;
    /** @type {?} */
    RelationMeta.prototype.VERSION_NO;
    /** @type {?} */
    RelationMeta.prototype.ATTRIBUTES;
    /** @type {?} */
    RelationMeta.prototype.ASSOCIATIONS;
}
class Association {
}
if (false) {
    /** @type {?} */
    Association.prototype.ASSOCIATION_NAME;
    /** @type {?} */
    Association.prototype.RIGHT_RELATION_ID;
    /** @type {?} */
    Association.prototype.CARDINALITY;
    /** @type {?} */
    Association.prototype.FOREIGN_KEY_CHECK;
    /** @type {?} */
    Association.prototype.FIELDS_MAPPING;
}
class FieldsMappingPair {
}
if (false) {
    /** @type {?} */
    FieldsMappingPair.prototype.LEFT_FIELD;
    /** @type {?} */
    FieldsMappingPair.prototype.RIGHT_FIELD;
}
class EntityRelation {
}
if (false) {
    /** @type {?} */
    EntityRelation.prototype.RELATION_ID;
    /** @type {?} */
    EntityRelation.prototype.RELATION_DESC;
    /** @type {?} */
    EntityRelation.prototype.CARDINALITY;
    /** @type {?} */
    EntityRelation.prototype.ROLE_ID;
    /** @type {?} */
    EntityRelation.prototype.CONDITIONAL_ATTR;
    /** @type {?} */
    EntityRelation.prototype.CONDITIONAL_VALUE;
    /** @type {?} */
    EntityRelation.prototype.EMPTY;
    /** @type {?} */
    EntityRelation.prototype.DISABLED;
    /** @type {?} */
    EntityRelation.prototype.ATTRIBUTES;
}
class Selection {
}
if (false) {
    /** @type {?} */
    Selection.prototype.RELATION_ID;
    /** @type {?} */
    Selection.prototype.FIELD_NAME;
    /** @type {?} */
    Selection.prototype.OPERATOR;
    /** @type {?} */
    Selection.prototype.LOW;
    /** @type {?} */
    Selection.prototype.HIGH;
}
class Projection {
}
if (false) {
    /** @type {?} */
    Projection.prototype.RELATION_ID;
    /** @type {?} */
    Projection.prototype.FIELD_NAME;
    /** @type {?} */
    Projection.prototype.ALIAS;
}
class QueryObject {
}
if (false) {
    /** @type {?} */
    QueryObject.prototype.ENTITY_ID;
    /** @type {?} */
    QueryObject.prototype.RELATION_ID;
    /** @type {?} */
    QueryObject.prototype.PROJECTION;
    /** @type {?} */
    QueryObject.prototype.FILTER;
    /** @type {?} */
    QueryObject.prototype.SORT;
}
class Sort {
}
if (false) {
    /** @type {?} */
    Sort.prototype.FIELD_NAME;
    /** @type {?} */
    Sort.prototype.RELATION_ID;
    /** @type {?} */
    Sort.prototype.ORDER;
}
class EntityType {
}
if (false) {
    /** @type {?} */
    EntityType.prototype.ENTITY_ID;
    /** @type {?} */
    EntityType.prototype.ENTITY_DESC;
    /** @type {?} */
    EntityType.prototype.VERSION_NO;
    /** @type {?} */
    EntityType.prototype.CREATE_BY;
    /** @type {?} */
    EntityType.prototype.CREATE_TIME;
    /** @type {?} */
    EntityType.prototype.LAST_CHANGE_BY;
    /** @type {?} */
    EntityType.prototype.LAST_CHANGE_TIME;
}
class Relation {
}
if (false) {
    /** @type {?} */
    Relation.prototype.RELATION_ID;
    /** @type {?} */
    Relation.prototype.RELATION_DESC;
    /** @type {?} */
    Relation.prototype.VERSION_NO;
    /** @type {?} */
    Relation.prototype.CREATE_BY;
    /** @type {?} */
    Relation.prototype.CREATE_TIME;
    /** @type {?} */
    Relation.prototype.LAST_CHANGE_BY;
    /** @type {?} */
    Relation.prototype.LAST_CHANGE_TIME;
}
class RelationshipH {
}
if (false) {
    /** @type {?} */
    RelationshipH.prototype.RELATIONSHIP_ID;
    /** @type {?} */
    RelationshipH.prototype.RELATIONSHIP_DESC;
    /** @type {?} */
    RelationshipH.prototype.VALID_PERIOD;
    /** @type {?} */
    RelationshipH.prototype.VERSION_NO;
    /** @type {?} */
    RelationshipH.prototype.CREATE_BY;
    /** @type {?} */
    RelationshipH.prototype.CREATE_TIME;
    /** @type {?} */
    RelationshipH.prototype.LAST_CHANGE_BY;
    /** @type {?} */
    RelationshipH.prototype.LAST_CHANGE_TIME;
}
class RoleH {
}
if (false) {
    /** @type {?} */
    RoleH.prototype.ROLE_ID;
    /** @type {?} */
    RoleH.prototype.ROLE_DESC;
    /** @type {?} */
    RoleH.prototype.VERSION_NO;
    /** @type {?} */
    RoleH.prototype.CREATE_BY;
    /** @type {?} */
    RoleH.prototype.CREATE_TIME;
    /** @type {?} */
    RoleH.prototype.LAST_CHANGE_BY;
    /** @type {?} */
    RoleH.prototype.LAST_CHANGE_TIME;
}
class RoleMeta {
}
if (false) {
    /** @type {?} */
    RoleMeta.prototype.ROLE_ID;
    /** @type {?} */
    RoleMeta.prototype.ROLE_DESC;
    /** @type {?} */
    RoleMeta.prototype.CREATE_BY;
    /** @type {?} */
    RoleMeta.prototype.CREATE_TIME;
    /** @type {?} */
    RoleMeta.prototype.LAST_CHANGE_BY;
    /** @type {?} */
    RoleMeta.prototype.LAST_CHANGE_TIME;
    /** @type {?} */
    RoleMeta.prototype.RELATIONS;
}
class DataElementH {
}
if (false) {
    /** @type {?} */
    DataElementH.prototype.ELEMENT_ID;
    /** @type {?} */
    DataElementH.prototype.ELEMENT_DESC;
    /** @type {?} */
    DataElementH.prototype.VERSION_NO;
    /** @type {?} */
    DataElementH.prototype.CREATE_BY;
    /** @type {?} */
    DataElementH.prototype.CREATE_TIME;
    /** @type {?} */
    DataElementH.prototype.LAST_CHANGE_BY;
    /** @type {?} */
    DataElementH.prototype.LAST_CHANGE_TIME;
}
class DataElementMeta {
}
if (false) {
    /** @type {?} */
    DataElementMeta.prototype.ELEMENT_ID;
    /** @type {?} */
    DataElementMeta.prototype.ELEMENT_DESC;
    /** @type {?} */
    DataElementMeta.prototype.LABEL_TEXT;
    /** @type {?} */
    DataElementMeta.prototype.LIST_HEADER_TEXT;
    /** @type {?} */
    DataElementMeta.prototype.DOMAIN_ID;
    /** @type {?} */
    DataElementMeta.prototype.DATA_TYPE;
    /** @type {?} */
    DataElementMeta.prototype.DATA_LENGTH;
    /** @type {?} */
    DataElementMeta.prototype.DECIMAL;
    /** @type {?} */
    DataElementMeta.prototype.SEARCH_HELP_ID;
    /** @type {?} */
    DataElementMeta.prototype.SEARCH_HELP_EXPORT_FIELD;
    /** @type {?} */
    DataElementMeta.prototype.PARAMETER_ID;
    /** @type {?} */
    DataElementMeta.prototype.VERSION_NO;
    /** @type {?} */
    DataElementMeta.prototype.CREATE_BY;
    /** @type {?} */
    DataElementMeta.prototype.CREATE_TIME;
    /** @type {?} */
    DataElementMeta.prototype.LAST_CHANGE_BY;
    /** @type {?} */
    DataElementMeta.prototype.LAST_CHANGE_TIME;
}
class DataDomainH {
}
if (false) {
    /** @type {?} */
    DataDomainH.prototype.DOMAIN_ID;
    /** @type {?} */
    DataDomainH.prototype.DOMAIN_DESC;
    /** @type {?} */
    DataDomainH.prototype.VERSION_NO;
    /** @type {?} */
    DataDomainH.prototype.CREATE_BY;
    /** @type {?} */
    DataDomainH.prototype.CREATE_TIME;
    /** @type {?} */
    DataDomainH.prototype.LAST_CHANGE_BY;
    /** @type {?} */
    DataDomainH.prototype.LAST_CHANGE_TIME;
}
class DataDomainMeta {
}
if (false) {
    /** @type {?} */
    DataDomainMeta.prototype.DOMAIN_ID;
    /** @type {?} */
    DataDomainMeta.prototype.DOMAIN_DESC;
    /** @type {?} */
    DataDomainMeta.prototype.DATA_TYPE;
    /** @type {?} */
    DataDomainMeta.prototype.DATA_LENGTH;
    /** @type {?} */
    DataDomainMeta.prototype.DOMAIN_TYPE;
    /** @type {?} */
    DataDomainMeta.prototype.DECIMAL;
    /** @type {?} */
    DataDomainMeta.prototype.UNSIGNED;
    /** @type {?} */
    DataDomainMeta.prototype.CAPITAL_ONLY;
    /** @type {?} */
    DataDomainMeta.prototype.REG_EXPR;
    /** @type {?} */
    DataDomainMeta.prototype.ENTITY_ID;
    /** @type {?} */
    DataDomainMeta.prototype.RELATION_ID;
    /** @type {?} */
    DataDomainMeta.prototype.DOMAIN_VALUES;
    /** @type {?} */
    DataDomainMeta.prototype.VERSION_NO;
    /** @type {?} */
    DataDomainMeta.prototype.CREATE_BY;
    /** @type {?} */
    DataDomainMeta.prototype.CREATE_TIME;
    /** @type {?} */
    DataDomainMeta.prototype.LAST_CHANGE_BY;
    /** @type {?} */
    DataDomainMeta.prototype.LAST_CHANGE_TIME;
}
class DataDomainValue {
}
if (false) {
    /** @type {?} */
    DataDomainValue.prototype.LOW_VALUE;
    /** @type {?} */
    DataDomainValue.prototype.LOW_VALUE_TEXT;
    /** @type {?} */
    DataDomainValue.prototype.HIGH_VALUE;
}

/**
 * @fileoverview added by tsickle
 * Generated from: lib/ui-mapper.service.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
class UiMapperService {
    constructor() {
    }
    /**
     * Map a FormGroup to a JOR relation(with cardinality [0..1] and [1..1]) for adding or updating.
     * @param {?} formGroup
     * @param {?} keys
     * @param {?=} isNew
     * @return {?}
     */
    composeChangedRelation(formGroup, keys, isNew = true) {
        if (!formGroup.dirty || !keys || Object.keys(keys).length === 0) {
            return {};
        }
        /** @type {?} */
        const changedRelation = { action: isNew ? 'add' : 'update' };
        Object.keys(keys).forEach((/**
         * @param {?} key
         * @return {?}
         */
        key => changedRelation[key] = keys[key] || formGroup.value[key]));
        Object.keys(formGroup.controls).forEach((/**
         * @param {?} key
         * @return {?}
         */
        key => {
            /** @type {?} */
            const control = formGroup.get(key);
            if (control.dirty) {
                changedRelation[key] = control.value;
            }
        }));
        return changedRelation;
    }
    /**
     * Map a FormArray to JOR relation(with cardinality [0..n] or [1..n]) for adding, updating, or deletion.
     * @param {?} formArray
     * @param {?} originalArray
     * @param {?} keys
     * @return {?}
     */
    composeChangedRelationArray(formArray, originalArray, keys) {
        if (!formArray.dirty || !keys || Object.keys(keys).length === 0) {
            return [];
        }
        if (!originalArray) {
            originalArray = [];
        }
        /** @type {?} */
        const changedRelationArray = [];
        formArray.controls.forEach((/**
         * @param {?} formGroup
         * @return {?}
         */
        formGroup => {
            if (formGroup.dirty) {
                /** @type {?} */
                const changedRelation = {};
                changedRelationArray.push(changedRelation);
                /** @type {?} */
                const index = originalArray.findIndex((/**
                 * @param {?} element
                 * @return {?}
                 */
                element => {
                    /** @type {?} */
                    let found = true;
                    Object.keys(keys).forEach((/**
                     * @param {?} key
                     * @return {?}
                     */
                    key => {
                        if (keys[key]) {
                            return;
                        }
                        found = found && (element[key] === formGroup.value[key]);
                    }));
                    return found;
                }));
                changedRelation['action'] = index === -1 ? 'add' : 'update';
                Object.keys(keys).forEach((/**
                 * @param {?} key
                 * @return {?}
                 */
                key => changedRelation[key] = keys[key] || formGroup.value[key]));
                Object.keys(formGroup['controls']).forEach((/**
                 * @param {?} key
                 * @return {?}
                 */
                key => {
                    /** @type {?} */
                    const control = formGroup.get(key);
                    if (control.dirty) {
                        changedRelation[key] = control.value;
                    }
                }));
            }
        }));
        originalArray.forEach((/**
         * @param {?} originalRelation
         * @return {?}
         */
        originalRelation => {
            /** @type {?} */
            const index = formArray.controls.findIndex((/**
             * @param {?} element
             * @return {?}
             */
            element => {
                /** @type {?} */
                let found = true;
                Object.keys(keys).forEach((/**
                 * @param {?} key
                 * @return {?}
                 */
                key => {
                    if (keys[key]) {
                        return;
                    }
                    found = found && (element.value[key] === originalRelation[key]);
                }));
                return found;
            }));
            if (index === -1) {
                /** @type {?} */
                const deletedRelation = { action: 'delete' };
                Object.keys(keys).forEach((/**
                 * @param {?} key
                 * @return {?}
                 */
                key => deletedRelation[key] = keys[key] || originalRelation[key]));
                changedRelationArray.push(deletedRelation);
            }
        }));
        return changedRelationArray;
    }
    /**
     * Map a FormArray to JOR relationships for adding, updating, or deletion.
     * @param {?} relationshipID
     * @param {?} partnerRoles
     * @param {?} formArray
     * @param {?} originalArray
     * @param {?} nonRelationshipAttributes
     * @return {?}
     */
    composeChangedRelationship(relationshipID, partnerRoles, formArray, originalArray, nonRelationshipAttributes) {
        if (!formArray.dirty) {
            return null;
        }
        /** @type {?} */
        const relationship = {
            RELATIONSHIP_ID: relationshipID,
            values: []
        };
        formArray.controls.forEach((/**
         * @param {?} formGroup
         * @return {?}
         */
        formGroup => {
            if (formGroup.dirty) {
                /** @type {?} */
                const changedRelationshipValue = {};
                relationship.values.push(changedRelationshipValue);
                if (formGroup.value['RELATIONSHIP_INSTANCE_GUID']) {
                    changedRelationshipValue['action'] = 'update';
                    changedRelationshipValue['RELATIONSHIP_INSTANCE_GUID'] = formGroup.value['RELATIONSHIP_INSTANCE_GUID'];
                }
                else {
                    changedRelationshipValue['action'] = 'add';
                    changedRelationshipValue['PARTNER_INSTANCES'] = [];
                    partnerRoles.forEach((/**
                     * @param {?} partnerRole
                     * @return {?}
                     */
                    partnerRole => changedRelationshipValue['PARTNER_INSTANCES'].push({
                        ENTITY_ID: partnerRole.ENTITY_ID,
                        ROLE_ID: partnerRole.ROLE_ID,
                        INSTANCE_GUID: formGroup.value[partnerRole.ROLE_ID + '_INSTANCE_GUID']
                    })));
                }
                Object.keys(formGroup['controls']).forEach((/**
                 * @param {?} key
                 * @return {?}
                 */
                key => {
                    if (nonRelationshipAttributes.includes(key) || key.substr(-13) === 'INSTANCE_GUID') {
                        return;
                    }
                    /** @type {?} */
                    const control = formGroup.get(key);
                    if (control.dirty) {
                        changedRelationshipValue[key] = control.value;
                    }
                }));
            }
        }));
        originalArray.forEach((/**
         * @param {?} original
         * @return {?}
         */
        original => {
            if (formArray.controls.findIndex((/**
             * @param {?} formGroup
             * @return {?}
             */
            formGroup => formGroup.value['RELATIONSHIP_INSTANCE_GUID'] === original['RELATIONSHIP_INSTANCE_GUID'])) === -1) {
                relationship.values.push({ action: 'delete', RELATIONSHIP_INSTANCE_GUID: original['RELATIONSHIP_INSTANCE_GUID'] });
            }
        }));
        return relationship.values.length === 0 ? null : relationship;
    }
}
UiMapperService.decorators = [
    { type: Injectable, args: [{
                providedIn: 'root'
            },] }
];
/** @nocollapse */
UiMapperService.ctorParameters = () => [];
/** @nocollapse */ UiMapperService.ɵprov = ɵɵdefineInjectable({ factory: function UiMapperService_Factory() { return new UiMapperService(); }, token: UiMapperService, providedIn: "root" });

/**
 * @fileoverview added by tsickle
 * Generated from: lib/entity.service.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
/** @type {?} */
const httpOptions = {
    headers: new HttpHeaders({ 'Content-Type': 'application/json' })
};
class EntityService {
    /**
     * @param {?} http
     * @param {?} messageService
     */
    constructor(http, messageService) {
        this.http = http;
        this.messageService = messageService;
        this.originalHost = '';
        this.fakeUUIDs = [];
        this.messageService.setMessageStore([
            { msgCat: 'EXCEPTION', msgName: 'GENERIC',
                msgText: { EN: { shortText: 'Exception Occurs in Operation: %s', longText: '%s2' } } },
            { msgCat: 'EXCEPTION', msgName: 'SESSION_EXPIRED',
                msgText: { EN: { shortText: 'Your session is expired',
                        longText: 'Your session is expired, please <a href="/logon">re-logon</a>' } } }
        ], 'EN');
    }
    /**
     * @param {?} host
     * @return {?}
     */
    setOriginalHost(host) {
        this.originalHost = host;
    }
    /**
     * @param {?} msgStore
     * @param {?} language
     * @return {?}
     */
    setMessageStore(msgStore, language) {
        this.messageService.setMessageStore(msgStore, language);
    }
    /**
     * List all entity IDs in the system
     * @return {?}
     */
    listEntityID() {
        return this.http.get(this.originalHost + `/api/entity/EntityIDs`).pipe(catchError(this.handleError('listEntityID')));
    }
    /**
     * List entity IDs by a given role ID
     * @param {?} roleID
     * @return {?}
     */
    listEntityIDbyRole(roleID) {
        return this.http.get(this.originalHost + `/api/entity/EntityIDs/${roleID}`).pipe(catchError(this.handleError('listEntityIDbyRole')));
    }
    /**
     * Return the entity meta for a given entity ID
     * @param {?} entityID
     * @return {?}
     */
    getEntityMeta(entityID) {
        return this.http.get(this.originalHost + `/api/entity/meta/${entityID}`).pipe(catchError(this.handleError('getEntityMeta')));
    }
    /**
     * Return a list of entity objects according to the description of a given query object
     * @param {?} queryObject
     * @return {?}
     */
    searchEntities(queryObject) {
        return this.http.post(this.originalHost + `/api/query`, queryObject, httpOptions).pipe(catchError(this.handleError('searchEntities')));
    }
    /**
     * Return an entity instance for a given entity instance GUID
     * @param {?} instanceGUID
     * @return {?}
     */
    getEntityInstance(instanceGUID) {
        return this.http.get(this.originalHost + `/api/entity/instance/${instanceGUID}`).pipe(catchError(this.handleError('getEntityInstance')));
    }
    /**
     * Return a relation's meta data for a given relation ID
     * @param {?} relationID
     * @return {?}
     */
    getRelationMeta(relationID) {
        return this.http.get(this.originalHost + `/api/relation/meta/${relationID}`).pipe(catchError(this.handleError('getRelationMeta')));
    }
    /**
     * Return all relations' meta data for a given entity ID
     * @param {?} entityID
     * @return {?}
     */
    getRelationMetaOfEntity(entityID) {
        return this.http.get(this.originalHost + `/api/relation/meta/entity/${entityID}`).pipe(catchError(this.handleError('getRelationMetaOfEntity')));
    }
    /**
     * Create a new entity instance
     * @param {?} instance
     * @return {?}
     */
    createEntityInstance(instance) {
        return this.http.post(this.originalHost + `/api/entity`, instance, httpOptions).pipe(catchError(this.handleError('createEntityInstance')));
    }
    /**
     * Change an existing entity instance
     * @param {?} instance
     * @return {?}
     */
    changeEntityInstance(instance) {
        return this.http.put(this.originalHost + `/api/entity`, instance, httpOptions).pipe(catchError(this.handleError('changeEntityInstance')));
    }
    /**
     * Delete an entity instance from a given instance GUID
     * @param {?} instanceGUID
     * @return {?}
     */
    deleteEntityInstance(instanceGUID) {
        return this.http.delete(this.originalHost + `/api/entity/instance/${instanceGUID}`).pipe(catchError(this.handleError('deleteEntityInstance')));
    }
    /**
     * Return entity types(IDs) for a given search term
     * @param {?} term
     * @return {?}
     */
    listEntityType(term) {
        return this.http.get(this.originalHost + `/api/model/entity-types?term=${term}`).pipe(catchError(this.handleError('listEntityType')));
    }
    /**
     * Return the description of a given entity type(ID)
     * @param {?} entityID
     * @return {?}
     */
    getEntityTypeDesc(entityID) {
        return this.http.get(this.originalHost + `/api/model/entity-types/${entityID}/desc`).pipe(catchError(this.handleError('getEntityTypeDesc')));
    }
    /**
     * Save an entity type after changing or creation
     * @param {?} entityType
     * @return {?}
     */
    saveEntityType(entityType) {
        return this.http.post(this.originalHost + `/api/model/entity-types`, entityType, httpOptions).pipe(catchError(this.handleError('saveEntityType')));
    }
    /**
     * Return a list of relations in the system according to the search term
     * @param {?} term
     * @return {?}
     */
    listRelation(term) {
        return this.http.get(this.originalHost + `/api/model/relations?term=${term}`).pipe(catchError(this.handleError('listRelation')));
    }
    /**
     * Return the description of a given relation ID
     * @param {?} relationID
     * @return {?}
     */
    getRelationDesc(relationID) {
        return this.http.get(this.originalHost + `/api/model/relations/${relationID}/desc`).pipe(catchError(this.handleError('getRelationDesc')));
    }
    /**
     * Save a relation after changing or creation
     * @param {?} relation
     * @return {?}
     */
    saveRelation(relation) {
        return this.http.post(this.originalHost + `/api/model/relations`, relation, httpOptions).pipe(catchError(this.handleError('saveRelation')));
    }
    /**
     * Return a list of relationships in the system according to the search term
     * @param {?} term
     * @return {?}
     */
    listRelationship(term) {
        return this.http.get(this.originalHost + `/api/model/relationships?term=${term}`).pipe(catchError(this.handleError('listRelationship')));
    }
    /**
     * Return a relationship definition from a given relationship ID
     * @param {?} relationshipID
     * @return {?}
     */
    getRelationship(relationshipID) {
        return this.http.get(this.originalHost + `/api/model/relationships/${relationshipID}`).pipe(catchError(this.handleError('getRelationship')));
    }
    /**
     * Return the description of a given relationship ID
     * @param {?} relationshipID
     * @return {?}
     */
    getRelationshipDesc(relationshipID) {
        return this.http.get(this.originalHost + `/api/model/relationships/${relationshipID}/desc`).pipe(catchError(this.handleError('getRelationshipDesc')));
    }
    /**
     * Save a relationship after changing or creation
     * @param {?} relationship
     * @return {?}
     */
    saveRelationship(relationship) {
        return this.http.post(this.originalHost + `/api/model/relationships`, relationship, httpOptions).pipe(catchError(this.handleError('saveRelationship')));
    }
    /**
     * Return a list of roles in the system according to the search term
     * @param {?} term
     * @return {?}
     */
    listRole(term) {
        return this.http.get(this.originalHost + `/api/model/roles?term=${term}`).pipe(catchError(this.handleError('listRole')));
    }
    /**
     * Return a role definition from a given role ID
     * @param {?} roleID
     * @return {?}
     */
    getRole(roleID) {
        return this.http.get(this.originalHost + `/api/model/roles/${roleID}`).pipe(catchError(this.handleError('getRole')));
    }
    /**
     * Return the description of a given role ID
     * @param {?} roleID
     * @return {?}
     */
    getRoleDesc(roleID) {
        return this.http.get(this.originalHost + `/api/model/roles/${roleID}/desc`).pipe(catchError(this.handleError('getRoleDesc')));
    }
    /**
     * Save a role after changing or creation
     * @param {?} role
     * @return {?}
     */
    saveRole(role) {
        return this.http.post(this.originalHost + `/api/model/roles`, role, httpOptions).pipe(catchError(this.handleError('saveRole')));
    }
    /**
     * Return a list of data elements in the system according to the search term
     * @param {?} term
     * @return {?}
     */
    listDataElement(term) {
        return this.http.get(this.originalHost + `/api/model/data-elements?term=${term}`).pipe(catchError(this.handleError('listDataElement')));
    }
    /**
     * Return a data element definition from a given element ID
     * @param {?} elementID
     * @return {?}
     */
    getDataElement(elementID) {
        return this.http.get(this.originalHost + `/api/model/data-elements/${elementID}`).pipe(catchError(this.handleError('getDataElement')));
    }
    /**
     * Return the description of a given data element ID
     * @param {?} elementID
     * @return {?}
     */
    getDataElementDesc(elementID) {
        return this.http.get(this.originalHost + `/api/model/data-elements/${elementID}/desc`).pipe(catchError(this.handleError('getDataElementDesc')));
    }
    /**
     * Save a data element after changing or creation
     * @param {?} element
     * @return {?}
     */
    saveDataElement(element) {
        return this.http.post(this.originalHost + `/api/model/data-elements`, element, httpOptions).pipe(catchError(this.handleError('saveDataElement')));
    }
    /**
     * Return a list of data domains in the system according to the search term
     * @param {?} term
     * @return {?}
     */
    listDataDomain(term) {
        return this.http.get(this.originalHost + `/api/model/data-domains?term=${term}`).pipe(catchError(this.handleError('listDataDomain')));
    }
    /**
     * Return a data domain definition from a given domain ID
     * @param {?} domainID
     * @return {?}
     */
    getDataDomain(domainID) {
        return this.http.get(this.originalHost + `/api/model/data-domains/${domainID}`).pipe(catchError(this.handleError('getDataDomain')));
    }
    /**
     * Return the description of a given data domain ID
     * @param {?} domainID
     * @return {?}
     */
    getDataDomainDesc(domainID) {
        return this.http.get(this.originalHost + `/api/model/data-domains/${domainID}/desc`).pipe(catchError(this.handleError('getDataDomainDesc')));
    }
    /**
     * Save a data domain after changing or creation
     * @param {?} domain
     * @return {?}
     */
    saveDataDomain(domain) {
        return this.http.post(this.originalHost + `/api/model/data-domains`, domain, httpOptions).pipe(catchError(this.handleError('saveDataDomain')));
    }
    /**
     * Get data element meta
     * @param {?} elementID
     * @return {?}
     */
    getElementMeta(elementID) {
        return this.http.get(this.originalHost + `/api/model/element-meta/${elementID}`).pipe(catchError(this.handleError('getElementMeta')));
    }
    /**
     * Return a fake relationship ID before saving
     * @return {?}
     */
    generateFakeRelationshipUUID() {
        /** @type {?} */
        const nextPosition = this.fakeUUIDs.length + 1;
        /** @type {?} */
        const fakeUUID = 'NewRelationship_' + nextPosition;
        this.fakeUUIDs.push(fakeUUID);
        return fakeUUID;
    }
    /**
     * @private
     * @template T
     * @param {?=} operation
     * @param {?=} result
     * @return {?}
     */
    handleError(operation = 'operation', result) {
        return (/**
         * @param {?} error
         * @return {?}
         */
        (error) => {
            // TODO: send the error to remote logging infrastructure
            console.error(error); // log to console instead
            if (error.status === 401) {
                this.messageService.addMessage('EXCEPTION', 'SESSION_EXPIRED', messageType.Exception);
            }
            else {
                this.messageService.addMessage('EXCEPTION', 'GENERIC', messageType.Exception, operation, error.message);
            }
            // Let the app keep running by returning an empty result.
            return of((/** @type {?} */ (result)));
        });
    }
}
EntityService.decorators = [
    { type: Injectable, args: [{
                providedIn: 'root'
            },] }
];
/** @nocollapse */
EntityService.ctorParameters = () => [
    { type: HttpClient },
    { type: MessageService }
];
/** @nocollapse */ EntityService.ɵprov = ɵɵdefineInjectable({ factory: function EntityService_Factory() { return new EntityService(ɵɵinject(HttpClient), ɵɵinject(MessageService)); }, token: EntityService, providedIn: "root" });
if (false) {
    /**
     * @type {?}
     * @private
     */
    EntityService.prototype.originalHost;
    /**
     * @type {?}
     * @private
     */
    EntityService.prototype.fakeUUIDs;
    /**
     * @type {?}
     * @private
     */
    EntityService.prototype.http;
    /**
     * @type {?}
     * @private
     */
    EntityService.prototype.messageService;
}

/**
 * @fileoverview added by tsickle
 * Generated from: lib/search-help/search-help.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
class SearchHelp {
}
if (false) {
    /** @type {?} */
    SearchHelp.prototype.OBJECT_NAME;
    /** @type {?} */
    SearchHelp.prototype.METHOD;
    /** @type {?} */
    SearchHelp.prototype.BEHAVIOUR;
    /** @type {?} */
    SearchHelp.prototype.MULTI;
    /** @type {?} */
    SearchHelp.prototype.FUZZY_SEARCH;
    /** @type {?} */
    SearchHelp.prototype.READ_ONLY;
    /** @type {?} */
    SearchHelp.prototype.ENTITY_ID;
    /** @type {?} */
    SearchHelp.prototype.RELATION_ID;
    /** @type {?} */
    SearchHelp.prototype.FIELDS;
}
class SearchHelpField {
}
if (false) {
    /** @type {?} */
    SearchHelpField.prototype.RELATION_ID;
    /** @type {?} */
    SearchHelpField.prototype.FIELD_NAME;
    /** @type {?} */
    SearchHelpField.prototype.FIELD_DESC;
    /** @type {?} */
    SearchHelpField.prototype.IMPORT;
    /** @type {?} */
    SearchHelpField.prototype.EXPORT;
    /** @type {?} */
    SearchHelpField.prototype.IE_FIELD_NAME;
    /** @type {?} */
    SearchHelpField.prototype.LIST_POSITION;
    /** @type {?} */
    SearchHelpField.prototype.FILTER_POSITION;
    /** @type {?} */
    SearchHelpField.prototype.FILTER_DISP_ONLY;
    /** @type {?} */
    SearchHelpField.prototype.DEFAULT_VALUE;
}

/**
 * @fileoverview added by tsickle
 * Generated from: lib/search-help/search-help.component.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
class SearchHelpComponent {
    /**
     * @param {?} fb
     * @param {?} entityService
     */
    constructor(fb, entityService) {
        this.fb = fb;
        this.entityService = entityService;
        this.isSearchHelpModalShown = false;
        this.isFilterShown = false;
        this.isSelectAllChecked = false;
        this.selectedIndex = -1;
        this.filterFields = [];
        this.listFields = [];
        this.listData = [];
    }
    /**
     * @return {?}
     */
    get displaySearchHelpModal() { return this.isSearchHelpModalShown ? 'block' : 'none'; }
    /**
     * @return {?}
     */
    ngOnInit() {
        this.filterFieldsFormGroup = this.fb.group({});
    }
    /**
     * @param {?} searchHelpMeta
     * @param {?} exportControl
     * @param {?=} afterExportFn
     * @return {?}
     */
    openSearchHelpModal(searchHelpMeta, exportControl, afterExportFn) {
        this.searchHelpMeta = searchHelpMeta;
        this.exportControl = exportControl;
        this.afterExportFn = afterExportFn;
        this.filterFieldsFormGroup = this.fb.group({});
        this.filterFields = this.searchHelpMeta.FIELDS.filter((/**
         * @param {?} fieldMeta
         * @return {?}
         */
        fieldMeta => fieldMeta.FILTER_POSITION));
        this.filterFields.sort((/**
         * @param {?} a
         * @param {?} b
         * @return {?}
         */
        (a, b) => a.FILTER_POSITION - b.FILTER_POSITION));
        this.filterFields.forEach((/**
         * @param {?} fieldMeta
         * @return {?}
         */
        fieldMeta => {
            if (fieldMeta.IMPORT) {
                /** @type {?} */
                const ieFieldName = fieldMeta.IE_FIELD_NAME || fieldMeta.FIELD_NAME;
                if (exportControl.get(ieFieldName)) {
                    fieldMeta.DEFAULT_VALUE = exportControl.get(ieFieldName).value;
                }
            }
            this.filterFieldsFormGroup.addControl(fieldMeta.FIELD_NAME, this.fb.control(fieldMeta.DEFAULT_VALUE));
        }));
        this.listFields = this.searchHelpMeta.FIELDS.filter((/**
         * @param {?} fieldMeta
         * @return {?}
         */
        fieldMeta => fieldMeta.LIST_POSITION));
        this.listFields.sort((/**
         * @param {?} a
         * @param {?} b
         * @return {?}
         */
        (a, b) => a.LIST_POSITION - b.LIST_POSITION));
        if (this.searchHelpMeta.BEHAVIOUR === 'A') {
            this.search();
            this.isFilterShown = false;
        }
        else {
            this.isFilterShown = true;
        }
        this.isSearchHelpModalShown = true;
    }
    /**
     * @param {?} entityID
     * @param {?} relationID
     * @param {?} exportControl
     * @param {?} readonly
     * @param {?=} exportField
     * @param {?=} domainID
     * @param {?=} afterExportFn
     * @return {?}
     */
    openSearchHelpModalByEntity(entityID, relationID, exportControl, readonly, exportField, domainID, afterExportFn) {
        /** @type {?} */
        const searchHelpMeta = new SearchHelp();
        searchHelpMeta.OBJECT_NAME = entityID;
        searchHelpMeta.METHOD = (/**
         * @param {?} entityService
         * @return {?}
         */
        function (entityService) {
            return (/**
             * @param {?} searchTerm
             * @return {?}
             */
            (searchTerm) => entityService.searchEntities(searchTerm));
        })(this.entityService);
        searchHelpMeta.BEHAVIOUR = 'M';
        searchHelpMeta.MULTI = false;
        searchHelpMeta.FUZZY_SEARCH = false;
        searchHelpMeta.FIELDS = [];
        searchHelpMeta.READ_ONLY = readonly;
        searchHelpMeta.ENTITY_ID = entityID;
        searchHelpMeta.RELATION_ID = relationID;
        this.entityService.getRelationMeta(relationID)
            .subscribe((/**
         * @param {?} data
         * @return {?}
         */
        data => {
            /** @type {?} */
            const relationMeta = (/** @type {?} */ (data));
            relationMeta.ATTRIBUTES.forEach((/**
             * @param {?} attribute
             * @return {?}
             */
            attribute => searchHelpMeta.FIELDS.push({
                FIELD_NAME: attribute.ATTR_NAME,
                FIELD_DESC: attribute.LIST_HEADER_TEXT,
                IE_FIELD_NAME: attribute.DOMAIN_ID === domainID ? exportField : null,
                IMPORT: attribute.PRIMARY_KEY || attribute.DOMAIN_ID === domainID,
                EXPORT: attribute.PRIMARY_KEY || attribute.DOMAIN_ID === domainID,
                LIST_POSITION: attribute.ORDER,
                FILTER_POSITION: attribute.ORDER
            })));
            searchHelpMeta.FIELDS.push({
                FIELD_NAME: 'INSTANCE_GUID',
                FIELD_DESC: 'Instance GUID',
                IMPORT: false,
                EXPORT: true,
                LIST_POSITION: 999,
                FILTER_POSITION: 0
            });
            this.openSearchHelpModal(searchHelpMeta, exportControl, afterExportFn);
        }));
    }
    /**
     * @return {?}
     */
    search() {
        /** @type {?} */
        let searchTerm;
        if (this.searchHelpMeta.FUZZY_SEARCH) {
            searchTerm = this.fuzzySearchTerm || '';
        }
        else {
            searchTerm = new QueryObject();
            searchTerm.ENTITY_ID = this.searchHelpMeta.ENTITY_ID;
            searchTerm.RELATION_ID = this.searchHelpMeta.RELATION_ID;
            searchTerm.FILTER = [];
            this.filterFields.forEach((/**
             * @param {?} fieldMeta
             * @return {?}
             */
            fieldMeta => {
                /** @type {?} */
                const fieldValue = this.filterFieldsFormGroup.get(fieldMeta.FIELD_NAME).value;
                if (fieldValue) {
                    if (fieldValue.includes('*') || fieldValue.includes('%')) {
                        searchTerm.FILTER.push({ FIELD_NAME: fieldMeta.FIELD_NAME, OPERATOR: 'CN', LOW: fieldValue });
                    }
                    else {
                        searchTerm.FILTER.push({ FIELD_NAME: fieldMeta.FIELD_NAME, OPERATOR: 'EQ', LOW: fieldValue });
                    }
                }
            }));
        }
        this.listData = [];
        this.isSelectAllChecked = false;
        if (typeof this.searchHelpMeta.METHOD === 'function') {
            /** @type {?} */
            const searchHelpMethod = (/** @type {?} */ (this.searchHelpMeta.METHOD));
            searchHelpMethod(searchTerm).subscribe((/**
             * @param {?} data
             * @return {?}
             */
            data => this._generateSearchList(data)));
        }
        else if (Array.isArray(this.searchHelpMeta.METHOD)) {
            this._generateSearchList(this.searchHelpMeta.METHOD);
        }
    }
    /**
     * @param {?} data
     * @return {?}
     */
    _generateSearchList(data) {
        data.forEach((/**
         * @param {?} item
         * @return {?}
         */
        item => {
            /** @type {?} */
            const listItem = { SELECTED: '' };
            this.listFields.forEach((/**
             * @param {?} field
             * @return {?}
             */
            field => listItem[field.FIELD_NAME] = item[field.FIELD_NAME]));
            this.listData.push(listItem);
        }));
    }
    /**
     * @param {?} $event
     * @return {?}
     */
    enterSearch($event) {
        if ($event.keyCode === 13) {
            this.search();
        }
    }
    /**
     * @return {?}
     */
    showFilter() {
        this.isFilterShown = true;
    }
    /**
     * @return {?}
     */
    hideFilter() {
        this.isFilterShown = false;
    }
    /**
     * @return {?}
     */
    selectAll() {
        this.isSelectAllChecked = !this.isSelectAllChecked;
        this.listData.forEach((/**
         * @param {?} data
         * @return {?}
         */
        data => data.SELECTED = !data.SELECTED));
    }
    /**
     * @return {?}
     */
    confirmSelection() {
        // TODO: Currently, only single selection is supported. Multiple selection in later time
        if (this.searchHelpMeta.READ_ONLY) {
            return;
        }
        this.listFields.forEach((/**
         * @param {?} listField
         * @return {?}
         */
        listField => {
            if (this.exportControl instanceof FormGroup) {
                /** @type {?} */
                const exportControl = (/** @type {?} */ (this.exportControl));
                /** @type {?} */
                const ieFieldName = listField.IE_FIELD_NAME || listField.FIELD_NAME;
                /** @type {?} */
                const exportFieldControl = exportControl.get(ieFieldName);
                if (listField.EXPORT && exportFieldControl) {
                    exportFieldControl.setValue(this.listData[this.selectedIndex][listField.FIELD_NAME]);
                    exportFieldControl.markAsDirty();
                }
            }
            else {
                if (listField.EXPORT) {
                    this.exportControl[listField.FIELD_NAME] = this.listData[this.selectedIndex][listField.FIELD_NAME];
                }
            }
        }));
        if (this.afterExportFn) {
            this.afterExportFn();
        }
        this.listData = [];
        this.isSearchHelpModalShown = false;
    }
    /**
     * @return {?}
     */
    closeSearchHelpModal() {
        this.isSearchHelpModalShown = false;
    }
}
SearchHelpComponent.decorators = [
    { type: Component, args: [{
                selector: 'dk-app-search-help',
                template: "<div class=\"modal fade\" id=\"searchHelp\" tabindex=\"-1\" role=\"dialog\"\n     [ngClass]=\"{'show': isSearchHelpModalShown}\" [ngStyle]=\"{'display': displaySearchHelpModal}\">\n  <div class=\"modal-dialog modal-dialog-centered modal-lg\" role=\"document\">\n    <div class=\"modal-content dk-search-help-content\">\n      <div class=\"modal-header dk-search-help-header\">\n        <h6 class=\"modal-title\" id=\"addRelationship\">{{searchHelpMeta?.OBJECT_NAME}} ({{listData.length}})</h6>\n        <button type=\"button\" class=\"close\" (click)=\"closeSearchHelpModal()\">\n          <span aria-hidden=\"true\">&times;</span>\n        </button>\n      </div>\n\n      <div class=\"modal-body\">\n        <div *ngIf=\"isFilterShown\" class=\"card mb-2\">\n          <div *ngIf=\"searchHelpMeta && searchHelpMeta.FUZZY_SEARCH\" class=\"mt-2 mx-2 row\">\n            <input type=\"text\" class=\"form-control\" placeholder=\"Search\" [(ngModel)]=\"fuzzySearchTerm\" (keyup)=\"enterSearch($event)\">\n          </div>\n          <div class=\"mt-2 mx-2 row\" [formGroup]=\"filterFieldsFormGroup\">\n            <div *ngFor=\"let filterField of filterFields\" class=\"col-6 form-group row\">\n              <label for=\"{{filterField.FIELD_NAME}}\" class=\"col-6 col-form-label col-form-label-sm text-right\">\n                {{filterField.FIELD_DESC}}:</label>\n              <input id=\"{{filterField.FIELD_NAME}}\" name=\"{{filterField.FIELD_NAME}}\" formControlName=\"{{filterField.FIELD_NAME}}\"\n                     type=\"text\" class=\"col-6 form-control form-control-sm\" [readonly]=\"filterField.FILTER_DISP_ONLY\" (keyup)=\"enterSearch($event)\">\n            </div>\n          </div>\n\n          <div class=\"mb-2\">\n            <button type=\"button\" id=\"search\" class=\"btn btn-sm btn-primary float-right mr-2\" (click)=\"search()\">\n              Search\n            </button>\n          </div>\n        </div>\n\n        <button *ngIf=\"!isFilterShown\" type=\"button\" class=\"btn btn-link float-right\" (click)=\"showFilter()\">Show Filter</button>\n        <button *ngIf=\"isFilterShown\" type=\"button\" class=\"btn btn-link float-right\" (click)=\"hideFilter()\">Hide Filter</button>\n\n        <table class=\"table table-bordered table-sm table-hover dk-search-table\">\n          <thead class=\"thead-light\">\n          <tr>\n            <th scope=\"col\">\n              <input *ngIf=\"searchHelpMeta?.MULTI\" type=\"checkbox\" [(ngModel)]=\"isSelectAllChecked\" (click)=\"selectAll()\">\n            </th>\n            <th *ngFor=\"let listField of listFields\">{{listField.FIELD_DESC}}</th>\n          </tr>\n          </thead>\n\n          <tbody>\n          <tr *ngFor=\"let item of listData; let i = index\">\n            <td>\n              <input *ngIf=\"!searchHelpMeta.MULTI\" type=\"radio\" name=\"selectedIndex\" [value]=\"i\" [(ngModel)]=\"selectedIndex\" (dblclick)=\"confirmSelection()\">\n              <input *ngIf=\"searchHelpMeta.MULTI\" type=\"checkbox\" [(ngModel)]=\"item.SELECTED\">\n            </td>\n            <td *ngFor=\"let listField of listFields\">{{item[listField.FIELD_NAME]}}</td>\n          </tr>\n          </tbody>\n        </table>\n      </div>\n\n      <div class=\"modal-footer dk-search-help-footer\">\n        <button type=\"button\" class=\"btn btn-sm btn-secondary\" (click)=\"closeSearchHelpModal()\">Cancel</button>\n        <button type=\"button\" class=\"btn btn-sm btn-primary\" (click)=\"confirmSelection()\" [disabled]=\"searchHelpMeta?.READ_ONLY\">Confirm</button>\n      </div>\n    </div>\n  </div>\n</div>\n",
                styles: [".dk-search-help-header{padding:.3rem .5rem;background-color:#e9ecef}.dk-search-help-footer{padding:.5rem}.dk-search-table{display:block;overflow:scroll;max-height:40rem;white-space:nowrap;border:none}.dk-search-help-content{border:1px solid rgba(0,0,0,.4);box-shadow:8px 5px 5px rgba(0,0,0,.2)}"]
            }] }
];
/** @nocollapse */
SearchHelpComponent.ctorParameters = () => [
    { type: FormBuilder },
    { type: EntityService }
];
if (false) {
    /** @type {?} */
    SearchHelpComponent.prototype.isSearchHelpModalShown;
    /** @type {?} */
    SearchHelpComponent.prototype.isFilterShown;
    /** @type {?} */
    SearchHelpComponent.prototype.isSelectAllChecked;
    /** @type {?} */
    SearchHelpComponent.prototype.searchHelpMeta;
    /** @type {?} */
    SearchHelpComponent.prototype.fuzzySearchTerm;
    /** @type {?} */
    SearchHelpComponent.prototype.selectedIndex;
    /** @type {?} */
    SearchHelpComponent.prototype.filterFields;
    /** @type {?} */
    SearchHelpComponent.prototype.listFields;
    /** @type {?} */
    SearchHelpComponent.prototype.filterFieldsFormGroup;
    /** @type {?} */
    SearchHelpComponent.prototype.exportControl;
    /** @type {?} */
    SearchHelpComponent.prototype.afterExportFn;
    /** @type {?} */
    SearchHelpComponent.prototype.listData;
    /**
     * @type {?}
     * @private
     */
    SearchHelpComponent.prototype.fb;
    /**
     * @type {?}
     * @private
     */
    SearchHelpComponent.prototype.entityService;
}

/**
 * @fileoverview added by tsickle
 * Generated from: lib/attribute/attribute-base.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
class AttributeBase {
    constructor() {
        this.dropdownList = [];
    }
}
if (false) {
    /** @type {?} */
    AttributeBase.prototype.controlType;
    /** @type {?} */
    AttributeBase.prototype.key;
    /** @type {?} */
    AttributeBase.prototype.name;
    /** @type {?} */
    AttributeBase.prototype.label;
    /** @type {?} */
    AttributeBase.prototype.list_label;
    /** @type {?} */
    AttributeBase.prototype.relationId;
    /** @type {?} */
    AttributeBase.prototype.maxLength;
    /** @type {?} */
    AttributeBase.prototype.step;
    /** @type {?} */
    AttributeBase.prototype.domainId;
    /** @type {?} */
    AttributeBase.prototype.placeholder;
    /** @type {?} */
    AttributeBase.prototype.pattern;
    /** @type {?} */
    AttributeBase.prototype.domainEntityId;
    /** @type {?} */
    AttributeBase.prototype.domainRelationId;
    /** @type {?} */
    AttributeBase.prototype.searchHelpId;
    /** @type {?} */
    AttributeBase.prototype.searchHelpExportField;
    /** @type {?} */
    AttributeBase.prototype.primaryKey;
    /** @type {?} */
    AttributeBase.prototype.autoIncrement;
    /** @type {?} */
    AttributeBase.prototype.dropdownList;
}
class DropdownList {
}
if (false) {
    /** @type {?} */
    DropdownList.prototype.key;
    /** @type {?} */
    DropdownList.prototype.value;
}

/**
 * @fileoverview added by tsickle
 * Generated from: lib/attribute/attribute-validators.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
// noinspection JSAnnotator
class DomainValueValidator {
    /**
     * @param {?} entityService
     */
    constructor(entityService) {
        this.entityService = entityService;
    }
    /**
     * @param {?} ctrl
     * @return {?}
     */
    validate(ctrl) {
        /** @type {?} */
        const queryObject = new QueryObject();
        // queryObject.ENTITY_ID = entityID;
        // queryObject.RELATION_ID = relationID;
        // queryObject.FILTER = [{FIELD_NAME: searchField, OPERATOR: 'EQ', LOW: ctrl.value}];
        return this.entityService.searchEntities(queryObject).pipe(map((/**
         * @param {?} data
         * @return {?}
         */
        data => {
            if (data['msgName']) {
                return { message: data['msgName']['msgShortText'] };
            }
            else {
                if (data.length === 0) {
                    return { message: 'Value is invalid' };
                }
                else {
                    return null;
                }
            }
        })), catchError((/**
         * @return {?}
         */
        () => null)));
    }
}
DomainValueValidator.decorators = [
    { type: Injectable, args: [{
                providedIn: 'root'
            },] }
];
/** @nocollapse */
DomainValueValidator.ctorParameters = () => [
    { type: EntityService }
];
/** @nocollapse */ DomainValueValidator.ɵprov = ɵɵdefineInjectable({ factory: function DomainValueValidator_Factory() { return new DomainValueValidator(ɵɵinject(EntityService)); }, token: DomainValueValidator, providedIn: "root" });
if (false) {
    /**
     * @type {?}
     * @private
     */
    DomainValueValidator.prototype.entityService;
}

/**
 * @fileoverview added by tsickle
 * Generated from: lib/attribute/attribute-control.service.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
class AttributeControlService {
    /**
     * @param {?} entityService
     * @param {?} domainValueValidator
     */
    constructor(entityService, domainValueValidator) {
        this.entityService = entityService;
        this.domainValueValidator = domainValueValidator;
    }
    /**
     * @param {?} attributes
     * @return {?}
     */
    toAttributeControl(attributes) {
        /** @type {?} */
        const attributeControls = [];
        if (!attributes) {
            return attributeControls;
        }
        attributes.forEach((/**
         * @param {?} attribute
         * @return {?}
         */
        attribute => attributeControls.push(this.toSingleAttributeControl(attribute))));
        return attributeControls;
    }
    /**
     * @param {?} attribute
     * @return {?}
     */
    toSingleAttributeControl(attribute) {
        /** @type {?} */
        const attributeControl = new AttributeBase();
        attributeControl.key = attribute.ATTR_GUID;
        attributeControl.name = attribute.ATTR_NAME;
        attributeControl.label = attribute.LABEL_TEXT;
        attributeControl.list_label = attribute.LIST_HEADER_TEXT;
        attributeControl.relationId = attribute.RELATION_ID;
        attributeControl.searchHelpId = attribute.SEARCH_HELP_ID;
        attributeControl.searchHelpExportField = attribute.SEARCH_HELP_EXPORT_FIELD;
        attributeControl.domainId = attribute.DOMAIN_ID;
        attributeControl.domainEntityId = attribute.DOMAIN_ENTITY_ID;
        attributeControl.domainRelationId = attribute.DOMAIN_RELATION_ID;
        switch (attribute.DATA_TYPE) {
            case 1: // Char
                if (attribute.CAPITAL_ONLY) {
                    attributeControl.controlType = 'text_capital';
                    // onkeyup="this.value = this.value.toUpperCase();"
                }
                else {
                    if (attribute.DOMAIN_TYPE === 3) {
                        attributeControl.controlType = 'dropdown';
                        this._generateDropdownList(attribute.DOMAIN_ID, attributeControl);
                    }
                    else {
                        attributeControl.controlType = 'text';
                        attributeControl.pattern = attribute.REG_EXPR;
                    }
                }
                attributeControl.maxLength = attribute.DATA_LENGTH;
                attributeControl.primaryKey = attribute.PRIMARY_KEY;
                break;
            case 2: // Integer
                if (attribute.DOMAIN_TYPE === 3) {
                    attributeControl.controlType = 'dropdown';
                    this._generateDropdownList(attribute.DOMAIN_ID, attributeControl);
                }
                else {
                    attributeControl.controlType = 'integer';
                    if (attribute.UNSIGNED) {
                        attributeControl.pattern = '^\\d+([^.,])?$';
                    }
                    attributeControl.autoIncrement = attribute.AUTO_INCREMENT;
                }
                attributeControl.primaryKey = attribute.PRIMARY_KEY;
                break;
            case 3: // Boolean
                attributeControl.controlType = 'checkbox';
                break;
            case 4: // Decimal
                attributeControl.controlType = 'decimal';
                this._setDecimalPattern(attributeControl, attribute);
                break;
            case 5: // String
                attributeControl.controlType = 'textarea';
                break;
            case 6: // Binary
                attributeControl.controlType = 'file';
                break;
            case 7: // Date
                attributeControl.controlType = 'date';
                break;
            case 8: // Timestamp
                attributeControl.controlType = 'timestamp';
                break;
            default:
                attributeControl.controlType = 'text';
        }
        return attributeControl;
    }
    /**
     * @param {?} domainID
     * @param {?} attributeControl
     * @return {?}
     */
    _generateDropdownList(domainID, attributeControl) {
        this.entityService.getDataDomain(domainID)
            .subscribe((/**
         * @param {?} dataDomain
         * @return {?}
         */
        dataDomain => dataDomain['DOMAIN_VALUES'].forEach((/**
         * @param {?} domainValue
         * @return {?}
         */
        domainValue => {
            attributeControl.dropdownList.push({
                key: domainValue['LOW_VALUE'],
                value: domainValue['LOW_VALUE_TEXT'] || domainValue['LOW_VALUE']
            });
        }))));
    }
    /**
     * @param {?} attributeControl
     * @param {?} attribute
     * @return {?}
     */
    _setDecimalPattern(attributeControl, attribute) {
        /** @type {?} */
        const zeroPadding = '0000000000000000000000000000000000000';
        attributeControl.step = '0.' + zeroPadding.substr(0, attribute.DECIMAL - 1) + '1';
        attributeControl.placeholder = '0.' + zeroPadding.substr(0, attribute.DECIMAL - 1) + '0';
        /** @type {?} */
        const integerPlace = attribute.DATA_LENGTH - attribute.DECIMAL;
        attributeControl.pattern = attribute.UNSIGNED ? '^(' : '^(\\-?';
        attributeControl.pattern += integerPlace ? '\\d{1,' + integerPlace.toString() + '})' : '0)';
        attributeControl.pattern += '(\\.\\d{1,' + attribute.DECIMAL + '})?$';
        attributeControl.maxLength = attribute.DATA_LENGTH;
    }
    /**
     * @param {?} attribute
     * @param {?} instance
     * @return {?}
     */
    convertToFormControl(attribute, instance) {
        /** @type {?} */
        const formControl = new FormControl(instance[attribute.ATTR_NAME] || '');
        if (attribute.PRIMARY_KEY && !attribute.AUTO_INCREMENT) {
            formControl.setValidators(Validators.required);
        }
        // if (attribute.DOMAIN_TYPE === 2 && !attribute.PRIMARY_KEY) {
        //   formControl.setAsyncValidators(this.domainValueValidator.validate.bind(this.domainValueValidator));
        // }
        return formControl;
    }
    /**
     * @param {?} attributes
     * @param {?} instance
     * @param {?=} isDirty
     * @return {?}
     */
    convertToFormGroup(attributes, instance, isDirty) {
        /** @type {?} */
        const group = {};
        attributes.forEach((/**
         * @param {?} attribute
         * @return {?}
         */
        attribute => {
            group[attribute.ATTR_NAME] = this.convertToFormControl(attribute, instance);
            if (instance[attribute.ATTR_NAME] && isDirty) {
                group[attribute.ATTR_NAME].markAsDirty();
            }
        }));
        return new FormGroup(group);
    }
}
AttributeControlService.decorators = [
    { type: Injectable, args: [{
                providedIn: 'root'
            },] }
];
/** @nocollapse */
AttributeControlService.ctorParameters = () => [
    { type: EntityService },
    { type: DomainValueValidator }
];
/** @nocollapse */ AttributeControlService.ɵprov = ɵɵdefineInjectable({ factory: function AttributeControlService_Factory() { return new AttributeControlService(ɵɵinject(EntityService), ɵɵinject(DomainValueValidator)); }, token: AttributeControlService, providedIn: "root" });
if (false) {
    /**
     * @type {?}
     * @private
     */
    AttributeControlService.prototype.entityService;
    /**
     * @type {?}
     * @private
     */
    AttributeControlService.prototype.domainValueValidator;
}

/**
 * @fileoverview added by tsickle
 * Generated from: lib/attribute/attribute.component.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
class AttributeComponent {
    constructor() {
    }
    /**
     * @return {?}
     */
    ngOnInit() {
        /** @type {?} */
        const fieldCtrl = this.formGroup.get(this.attributeControl.name);
        switch (this.attributeControl.controlType) {
            case 'timestamp':
                if (!this.readonly && !fieldCtrl.value) {
                    /** @type {?} */
                    const currentTimestamp = new Date();
                    fieldCtrl.setValue(currentTimestamp.getFullYear() + '-' + ('0' + (currentTimestamp.getMonth() + 1)).slice(-2) + '-'
                        + ('0' + currentTimestamp.getDate()).slice(-2) + ' ' + ('0' + currentTimestamp.getHours()).slice(-2) +
                        ':' + ('0' + currentTimestamp.getMinutes()).slice(-2) + ':' + ('0' + currentTimestamp.getSeconds()).slice(-2));
                    fieldCtrl.markAsDirty();
                }
                break;
            case 'date':
                if (!this.readonly && !fieldCtrl.value) {
                    /** @type {?} */
                    const currentDate = new Date();
                    fieldCtrl.setValue(currentDate.getFullYear() + '-' + ('0' + (currentDate.getMonth() + 1)).slice(-2) + '-'
                        + ('0' + currentDate.getDate()).slice(-2));
                    fieldCtrl.markAsDirty();
                }
                break;
            default:
        }
    }
    /**
     * @return {?}
     */
    ngOnChanges() {
        if (this.attributeControl.controlType === 'dropdown' ||
            this.attributeControl.controlType === 'checkbox') {
            this.readonly ? this.formGroup.get(this.attributeControl.name).disable() :
                this.formGroup.get(this.attributeControl.name).enable();
        }
    }
    /**
     * @return {?}
     */
    get invalid() { return this.formGroup.controls[this.attributeControl.name].invalid; }
    /**
     * @return {?}
     */
    get errorMessage() {
        /** @type {?} */
        const fieldCtrl = this.formGroup.get(this.attributeControl.name);
        if (fieldCtrl.getError('pattern')) {
            return 'The pattern is not correct';
        }
        else if (fieldCtrl.getError('required')) {
            return 'Required';
        }
        else if (fieldCtrl.getError('message')) {
            return fieldCtrl.getError('message');
        }
        else {
            return null;
        }
    }
    /**
     * @return {?}
     */
    get isReadonly() { return this.readonly || this.attributeControl.autoIncrement; }
    /**
     * @param {?} attributeName
     * @return {?}
     */
    onKeyup(attributeName) {
        /** @type {?} */
        const fieldCtrl = this.formGroup.get(attributeName);
        fieldCtrl.setValue(fieldCtrl.value.toUpperCase());
    }
    /**
     * @param {?} attributeControl
     * @return {?}
     */
    onSearchHelp(attributeControl) {
        this.searchHelpComponent.openSearchHelpModalByEntity(attributeControl.domainEntityId, attributeControl.domainRelationId, this.formGroup, this.readonly, attributeControl.name, attributeControl.domainId);
    }
}
AttributeComponent.decorators = [
    { type: Component, args: [{
                selector: 'dk-app-attribute',
                template: "<div [formGroup]=\"formGroup\">\n  <div [ngSwitch]=\"attributeControl.controlType\">\n    <div class=\"input-group\">\n      <input *ngSwitchCase=\"'text'\" type=\"text\" class=\"form-control\"\n             [class.form-control-sm] = \"isSmallSize\"\n             [formControlName]=\"attributeControl.name\"\n             [id]=\"attributeControl.key\"\n             [maxlength]=\"attributeControl.maxLength\"\n             [pattern]=\"attributeControl.pattern\"\n             [readonly]=\"isReadonly\" >\n      <input *ngSwitchCase=\"'text_capital'\" type=\"text\" class=\"form-control\"\n             [class.form-control-sm] = \"isSmallSize\"\n             [formControlName]=\"attributeControl.name\"\n             [id]=\"attributeControl.key\"\n             [maxlength]=\"attributeControl.maxLength\"\n             (keyup)=\"onKeyup(attributeControl.name)\"\n             [readonly]=\"isReadonly\" >\n      <input *ngSwitchCase=\"'integer'\" type=\"number\" class=\"form-control\"\n             [class.form-control-sm] = \"isSmallSize\"\n             [formControlName]=\"attributeControl.name\"\n             [id]=\"attributeControl.key\"\n             [pattern]=\"attributeControl.pattern\"\n             [readonly]=\"isReadonly\" >\n      <div *ngIf=\"attributeControl.searchHelpId || attributeControl.domainRelationId\" class=\"input-group-append\">\n        <button class=\"btn btn-outline-secondary btn-sm\" type=\"button\" (click)=\"onSearchHelp(attributeControl)\">\n          <span class=\"fas fa-search\"></span>\n        </button>\n      </div>\n    </div>\n    <input *ngSwitchCase=\"'decimal'\" type=\"number\" class=\"form-control\"\n           [class.form-control-sm] = \"isSmallSize\"\n           [formControlName]=\"attributeControl.name\"\n           [id]=\"attributeControl.key\"\n           [step]=\"attributeControl.step\"\n           [placeholder]=\"attributeControl.placeholder\"\n           [pattern]=\"attributeControl.pattern\"\n           [readonly]=\"isReadonly\" >\n    <input *ngSwitchCase=\"'checkbox'\" type=\"checkbox\" class=\"form-control\"\n           [class.form-control-sm] = \"isSmallSize\"\n           [formControlName]=\"attributeControl.name\"\n           [id]=\"attributeControl.key\">\n    <input *ngSwitchCase=\"'textarea'\" type=\"textarea\" class=\"form-control\"\n           [class.form-control-sm] = \"isSmallSize\"\n           [formControlName]=\"attributeControl.name\"\n           [id]=\"attributeControl.key\"\n           [readonly]=\"isReadonly\" >\n    <input *ngSwitchCase=\"'file'\" type=\"file\" class=\"form-control\"\n           [class.form-control-sm] = \"isSmallSize\"\n           [formControlName]=\"attributeControl.name\"\n           [id]=\"attributeControl.key\"\n           [readonly]=\"isReadonly\" >\n    <input *ngSwitchCase=\"'date'\" type=\"date\" class=\"form-control\"\n           [class.form-control-sm] = \"isSmallSize\"\n           [formControlName]=\"attributeControl.name\"\n           [id]=\"attributeControl.key\"\n           [readonly]=\"isReadonly\" >\n    <input *ngSwitchCase=\"'timestamp'\" type=\"text\" class=\"form-control\"\n           [class.form-control-sm] = \"isSmallSize\"\n           [formControlName]=\"attributeControl.name\"\n           [id]=\"attributeControl.key\"\n           [readonly]=\"isReadonly\" >\n    <select *ngSwitchCase=\"'dropdown'\" class=\"form-control\"\n            [class.form-control-sm] = \"isSmallSize\"\n            [formControlName]=\"attributeControl.name\"\n            [id]=\"attributeControl.key\">\n      <option *ngFor=\"let opt of attributeControl.dropdownList\" [value]=\"opt.key\">{{opt.value}}</option>\n    </select>\n  </div>\n\n  <div *ngIf=\"!noErrorMsg\" [class.ng-invalid]=\"invalid\" class=\"dk-invalid-feedback\">\n    {{errorMessage}}\n  </div>\n</div>\n\n<dk-app-search-help></dk-app-search-help>\n",
                styles: [""]
            }] }
];
/** @nocollapse */
AttributeComponent.ctorParameters = () => [];
AttributeComponent.propDecorators = {
    attributeControl: [{ type: Input }],
    formGroup: [{ type: Input }],
    readonly: [{ type: Input }],
    isSmallSize: [{ type: Input }],
    noErrorMsg: [{ type: Input }],
    searchHelpComponent: [{ type: ViewChild, args: [SearchHelpComponent, { static: false },] }]
};
if (false) {
    /** @type {?} */
    AttributeComponent.prototype.attributeControl;
    /** @type {?} */
    AttributeComponent.prototype.formGroup;
    /** @type {?} */
    AttributeComponent.prototype.readonly;
    /** @type {?} */
    AttributeComponent.prototype.isSmallSize;
    /** @type {?} */
    AttributeComponent.prototype.noErrorMsg;
    /**
     * @type {?}
     * @private
     */
    AttributeComponent.prototype.searchHelpComponent;
}

/**
 * @fileoverview added by tsickle
 * Generated from: lib/attribute/attribute-form/attribute-form.component.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
class AttributeFormComponent {
    constructor() {
    }
    /**
     * @return {?}
     */
    ngOnInit() {
    }
}
AttributeFormComponent.decorators = [
    { type: Component, args: [{
                selector: 'dk-app-attribute-form',
                template: "<div class=\"form-group row\" [formGroup]=\"formGroup\">\n  <label class=\"col-4 col-form-label text-right\"\n         [class.form-control-sm]=\"isSmallSize\"\n         [attr.for]=\"attributeControl.key\">\n    {{attributeControl.label}}<strong *ngIf=\"attributeControl.primaryKey\" class=\"primaryKey\">*</strong>:\n  </label>\n\n  <dk-app-attribute class=\"col-8\" [attributeControl]=\"attributeControl\" [formGroup]=\"formGroup\"\n                 [isSmallSize]=\"isSmallSize\" [readonly]=\"readonly\">\n  </dk-app-attribute>\n\n</div>\n",
                styles: [""]
            }] }
];
/** @nocollapse */
AttributeFormComponent.ctorParameters = () => [];
AttributeFormComponent.propDecorators = {
    attributeControl: [{ type: Input }],
    formGroup: [{ type: Input }],
    readonly: [{ type: Input }],
    isSmallSize: [{ type: Input }]
};
if (false) {
    /** @type {?} */
    AttributeFormComponent.prototype.attributeControl;
    /** @type {?} */
    AttributeFormComponent.prototype.formGroup;
    /** @type {?} */
    AttributeFormComponent.prototype.readonly;
    /** @type {?} */
    AttributeFormComponent.prototype.isSmallSize;
}

/**
 * @fileoverview added by tsickle
 * Generated from: lib/attribute/attribute-form2/attribute-form2.component.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
class AttributeForm2Component {
    constructor() {
    }
    /**
     * @return {?}
     */
    ngOnInit() {
    }
    /**
     * @return {?}
     */
    get invalid() { return this.formGroup.controls[this.attributeControl.name].invalid; }
    /**
     * @return {?}
     */
    get errorMessage() {
        /** @type {?} */
        const fieldCtrl = this.formGroup.get(this.attributeControl.name);
        if (fieldCtrl.getError('pattern')) {
            return 'The pattern is not correct';
        }
        else if (fieldCtrl.getError('required')) {
            return 'Required';
        }
        else if (fieldCtrl.getError('message')) {
            return fieldCtrl.getError('message');
        }
        else {
            return null;
        }
    }
}
AttributeForm2Component.decorators = [
    { type: Component, args: [{
                selector: 'dk-app-attribute-form2',
                template: "<div class=\"form-group\" [formGroup]=\"formGroup\">\n  <label class=\"col-form-label\"\n         [class.form-control-sm]=\"isSmallSize\"\n         [attr.for]=\"attributeControl.key\">\n    {{attributeControl.label}}<strong *ngIf=\"attributeControl.primaryKey\" class=\"primaryKey\">*</strong>:\n    <span [class.ng-invalid]=\"invalid\" class=\"dk-invalid-feedback\">{{errorMessage}}</span>\n  </label>\n\n  <dk-app-attribute [attributeControl]=\"attributeControl\" [formGroup]=\"formGroup\"\n                    [isSmallSize]=\"isSmallSize\" [readonly]=\"readonly\" [noErrorMsg]=\"true\">\n  </dk-app-attribute>\n\n</div>\n",
                styles: [""]
            }] }
];
/** @nocollapse */
AttributeForm2Component.ctorParameters = () => [];
AttributeForm2Component.propDecorators = {
    attributeControl: [{ type: Input }],
    formGroup: [{ type: Input }],
    readonly: [{ type: Input }],
    isSmallSize: [{ type: Input }]
};
if (false) {
    /** @type {?} */
    AttributeForm2Component.prototype.attributeControl;
    /** @type {?} */
    AttributeForm2Component.prototype.formGroup;
    /** @type {?} */
    AttributeForm2Component.prototype.readonly;
    /** @type {?} */
    AttributeForm2Component.prototype.isSmallSize;
}

/**
 * @fileoverview added by tsickle
 * Generated from: lib/attribute/attribute-table/attribute-table.component.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
class AttributeTableComponent {
    constructor() {
        this.isDetailModalShown = false;
        this.isErrorModalShown = false;
    }
    /**
     * @return {?}
     */
    ngOnInit() {
    }
    /**
     * @return {?}
     */
    get displayDetailModal() { return this.isDetailModalShown ? 'block' : 'none'; }
    /**
     * @return {?}
     */
    get displayErrorModal() { return this.isErrorModalShown ? 'block' : 'none'; }
    /**
     * @param {?} index
     * @return {?}
     */
    openDetailModal(index) {
        this.currentFormGroup = this.formArray.at(index);
        this.isDetailModalShown = true;
    }
    /**
     * @return {?}
     */
    closeDetailModal() {
        if (!this.readonly && this.currentFormGroup.dirty) {
            this.currentFormGroup.setValue(this.currentFormGroup.value); // Or the value won't be updated.
        }
        this.isDetailModalShown = false;
    }
    /**
     * @param {?} errorTitle
     * @param {?} errorDescription
     * @return {?}
     */
    openErrorModal(errorTitle, errorDescription) {
        this.errorTitle = errorTitle;
        this.errorDescription = errorDescription;
        this.isErrorModalShown = true;
    }
    /**
     * @return {?}
     */
    closeErrorModal() {
        this.isErrorModalShown = false;
    }
    /**
     * @param {?=} index
     * @return {?}
     */
    deleteRelationInstance(index = 0) {
        switch (this.entityRelation.CARDINALITY) {
            case '[0..n]':
                this.formArray.removeAt(index);
                this.formArray.markAsDirty();
                if (this.formArray.length === 0) {
                    this.entityRelation.EMPTY = true;
                }
                break;
            case '[1..n]':
                if (this.formArray.length === 1) {
                    this.openErrorModal('Deletion Fail', 'The relation requires at lease one entry!');
                }
                else {
                    this.formArray.removeAt(index);
                    this.formArray.markAsDirty();
                }
        }
    }
}
AttributeTableComponent.decorators = [
    { type: Component, args: [{
                selector: 'dk-app-attribute-table',
                template: "<table class=\"table table-bordered relation-table\"\n       [class.table-sm]=\"isSmallSize\"\n       [formGroup]=\"parentFormGroup\">\n  <thead class=\"thead-light\">\n  <tr>\n    <th scope=\"col\">\n      Action\n    </th>\n    <th scope=\"col\" *ngFor=\"let attributeControl of attributeControls\">\n      {{attributeControl.label}}<strong *ngIf=\"attributeControl.primaryKey\" class=\"primaryKey\">*</strong>\n    </th>\n  </tr>\n  </thead>\n\n  <tbody [formArrayName]=\"entityRelation.RELATION_ID\">\n    <tr *ngFor=\"let formGroup of formArray.controls; let i = index\">\n      <td class=\"actions\">\n        <button class=\"btn\" [class.btn-sm]=\"isSmallSize\" type=\"button\" (click)=\"openDetailModal(i)\" title=\"Detail\">\n          <span *ngIf=\"readonly\" class=\"fas fa-search\"></span>\n          <span *ngIf=\"!readonly\" class=\"fas fa-pen\"></span>\n        </button>\n        <button class=\"btn\" [class.btn-sm]=\"isSmallSize\" type=\"button\" [disabled]=\"readonly\" (click)=\"deleteRelationInstance(i)\" title=\"Delete\">\n          <span class=\"far fa-trash-alt\"></span>\n        </button>\n      </td>\n      <td *ngFor=\"let attributeControl of attributeControls\">\n        <dk-app-attribute [attributeControl]=\"attributeControl\" [isSmallSize] = \"isSmallSize\"\n                          [formGroup]=\"formGroup\" [readonly]=\"readonly\">\n\n        </dk-app-attribute>\n      </td>\n    </tr>\n  </tbody>\n</table>\n\n<div *ngIf=\"currentFormGroup\" class=\"modal fade dk-modal-open\" [ngClass]=\"{'show': isDetailModalShown}\"\n     [ngStyle]=\"{'display': displayDetailModal}\" id=\"detailModal\" tabindex=\"-1\" role=\"dialog\">\n  <div class=\"modal-dialog modal-lg\" role=\"document\">\n    <div class=\"modal-content\">\n      <div class=\"modal-header\">\n        <h5 class=\"modal-title\" id=\"detail\">Line Detail</h5>\n        <button type=\"button\" class=\"close\" (click)=\"closeDetailModal()\">\n          <span aria-hidden=\"true\">&times;</span>\n        </button>\n      </div>\n      <div class=\"modal-body\">\n        <dk-app-attribute-form *ngFor=\"let attributeControl of attributeControls\"\n                               [readonly]=\"readonly\" [isSmallSize]=\"isSmallSize\"\n                            [attributeControl]=\"attributeControl\" [formGroup]=\"currentFormGroup\">\n        </dk-app-attribute-form>\n      </div>\n      <div class=\"modal-footer\">\n        <button type=\"button\" class=\"btn btn-primary\" [class.btn-sm]=\"isSmallSize\" (click)=\"closeDetailModal()\">OK</button>\n      </div>\n    </div>\n  </div>\n</div>\n\n<div class=\"modal fade\" [ngClass]=\"{'show': isErrorModalShown}\"\n     [ngStyle]=\"{'display': displayErrorModal}\" id=\"errorModal\" tabindex=\"-1\" role=\"dialog\">\n  <div class=\"modal-dialog\" role=\"document\">\n    <div class=\"modal-content\">\n      <div class=\"modal-header\">\n        <h5 class=\"modal-title\" id=\"error\">{{errorTitle}}</h5>\n        <button type=\"button\" class=\"close\" (click)=\"closeErrorModal()\">\n          <span aria-hidden=\"true\">&times;</span>\n        </button>\n      </div>\n      <div class=\"modal-body\">\n        <p>{{errorDescription}}</p>\n      </div>\n      <div class=\"modal-footer\">\n        <button type=\"button\" class=\"btn btn-primary\" [class.btn-sm]=\"isSmallSize\" (click)=\"closeErrorModal()\">OK</button>\n      </div>\n    </div>\n  </div>\n</div>\n\n",
                styles: [".relation-table{display:block;overflow-x:auto;white-space:nowrap;border:none}.actions{width:5rem;min-width:5rem;max-width:6rem}.dk-modal-open{overflow:auto}"]
            }] }
];
/** @nocollapse */
AttributeTableComponent.ctorParameters = () => [];
AttributeTableComponent.propDecorators = {
    attributeControls: [{ type: Input }],
    formArray: [{ type: Input }],
    parentFormGroup: [{ type: Input }],
    entityRelation: [{ type: Input }],
    isSmallSize: [{ type: Input }],
    readonly: [{ type: Input }]
};
if (false) {
    /** @type {?} */
    AttributeTableComponent.prototype.isDetailModalShown;
    /** @type {?} */
    AttributeTableComponent.prototype.currentFormGroup;
    /** @type {?} */
    AttributeTableComponent.prototype.isErrorModalShown;
    /** @type {?} */
    AttributeTableComponent.prototype.errorTitle;
    /** @type {?} */
    AttributeTableComponent.prototype.errorDescription;
    /** @type {?} */
    AttributeTableComponent.prototype.attributeControls;
    /** @type {?} */
    AttributeTableComponent.prototype.formArray;
    /** @type {?} */
    AttributeTableComponent.prototype.parentFormGroup;
    /** @type {?} */
    AttributeTableComponent.prototype.entityRelation;
    /** @type {?} */
    AttributeTableComponent.prototype.isSmallSize;
    /** @type {?} */
    AttributeTableComponent.prototype.readonly;
}

/**
 * @fileoverview added by tsickle
 * Generated from: lib/jor-angular.component.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
class JorAngularComponent {
    constructor() {
    }
    /**
     * @return {?}
     */
    ngOnInit() {
    }
}
JorAngularComponent.decorators = [
    { type: Component, args: [{
                selector: 'dk-jor-angular',
                template: "<!-- html content -->\n",
                encapsulation: ViewEncapsulation.None,
                styles: ["input.ng-invalid,select.ng-invalid{border-color:#dc3545}.ng-invalid+.invalid-tooltip{display:block;max-width:inherit}.ng-invalid+.dk-invalid-feedback,.ng-invalid.dk-invalid-feedback{display:inline}.dk-invalid-feedback{display:none;width:100%;margin-top:.25rem;font-size:80%;color:#dc3545}.primaryKey{color:red}.errorMessage{color:red;font-size:.8rem}"]
            }] }
];
/** @nocollapse */
JorAngularComponent.ctorParameters = () => [];

/**
 * @fileoverview added by tsickle
 * Generated from: lib/jor-angular.module.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
class JorAngularModule {
}
JorAngularModule.decorators = [
    { type: NgModule, args: [{
                declarations: [
                    JorAngularComponent,
                    SearchHelpComponent,
                    AttributeComponent,
                    AttributeFormComponent,
                    AttributeTableComponent,
                    AttributeForm2Component
                ],
                imports: [
                    CommonModule,
                    HttpClientModule,
                    FormsModule,
                    ReactiveFormsModule
                ],
                exports: [
                    JorAngularComponent,
                    SearchHelpComponent,
                    AttributeComponent,
                    AttributeFormComponent,
                    AttributeForm2Component,
                    AttributeTableComponent
                ]
            },] }
];

/**
 * @fileoverview added by tsickle
 * Generated from: public_api.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */

/**
 * @fileoverview added by tsickle
 * Generated from: jor-angular.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */

export { Association, Attribute, AttributeBase, AttributeComponent, AttributeControlService, AttributeForm2Component, AttributeFormComponent, AttributeTableComponent, DataDomainH, DataDomainMeta, DataDomainValue, DataElementH, DataElementMeta, Entity, EntityMeta, EntityRelation, EntityService, EntityType, FieldsMappingPair, Involve, JorAngularModule, PartnerInstance, PartnerRole, Projection, QueryObject, Relation, RelationMeta, Relationship, RelationshipH, RelationshipInstance, RelationshipMeta, Role, RoleH, RoleMeta, RoleRelation, SearchHelp, SearchHelpComponent, SearchHelpField, Selection, Sort, UiMapperService, DomainValueValidator as ɵa, JorAngularComponent as ɵb };
//# sourceMappingURL=jor-angular.js.map
