import { ViewColumn, ViewEntity } from "typeorm";

@ViewEntity({
  expression: `SELECT 
        \`profileChild\`.\`id\` AS \`Id\`,
        \`profileChild\`.\`prefix\` AS \`prefix\`,
        \`profileChild\`.\`firstName\` AS \`firstName\`,
        \`profileChild\`.\`lastName\` AS \`lastName\`,
        \`profileChild\`.\`citizenId\` AS \`citizenId\`,
        \`profileChild\`.\`position\` AS \`position\`,
        \`profile\`.\`isProbation\` AS \`isProbation\`,
        CONCAT((CASE
                    WHEN (\`posMaster\`.\`orgChild1Id\` IS NULL) THEN \`orgRootChild\`.\`orgRootShortName\`
                    WHEN (\`posMaster\`.\`orgChild2Id\` IS NULL) THEN \`orgChild1Child\`.\`orgChild1ShortName\`
                    WHEN (\`posMaster\`.\`orgChild3Id\` IS NULL) THEN \`orgChild2Child\`.\`orgChild2ShortName\`
                    WHEN (\`posMaster\`.\`orgChild4Id\` IS NULL) THEN \`orgChild3Child\`.\`orgChild3ShortName\`
                    ELSE \`orgChild4Child\`.\`orgChild4ShortName\`
                END),
                \`posMaster\`.\`posMasterNo\`) AS \`posNo\`,
        \`posMasterChild\`.\`isDirector\` AS \`isDirectorChild\`,
        \`posMaster\`.\`isDirector\` AS \`isDirector\`,
        \`posLevel\`.\`posLevelName\` AS \`posLevel\`,
        \`posType\`.\`posTypeName\` AS \`posType\`,
        \`posExecutive\`.\`posExecutiveName\` AS \`posExecutiveName\`,
        \`orgRoot\`.\`isDeputy\` AS \`isDeputy\`,
        \`orgChild1\`.\`isOfficer\` AS \`isOfficer\`,
        \`posMaster\`.\`orgRevisionId\` AS \`orgRevisionId\`,
        \`posMaster\`.\`orgRootId\` AS \`orgRootId\`,
        \`posMaster\`.\`orgChild1Id\` AS \`orgChild1Id\`,
        \`posMaster\`.\`orgChild2Id\` AS \`orgChild2Id\`,
        \`posMaster\`.\`orgChild3Id\` AS \`orgChild3Id\`,
        \`posMaster\`.\`orgChild4Id\` AS \`orgChild4Id\`,
        \`posMaster\`.\`positionSign\` AS \`positionSign\`,
        CONCAT(\`hrms_organization\`.\`posMaster\`.\`id\`,
                \`profileChild\`.\`id\`) AS \`key\`,
        \`hrms_organization\`.\`profile\`.\`id\` AS \`actFullNameId\`,
        \`hrms_organization\`.\`profile\`.\`keycloak\` AS \`actFullNameKeycloakId\`,
        CONCAT(\`posMaster\`.\`id\`, \`profileChild\`.\`id\`) AS \`key\`,
        \`profile\`.\`id\` AS \`actFullNameId\`,
        CONCAT(\`profile\`.\`prefix\`,
                \`profile\`.\`firstName\`,
                ' ',
                \`profile\`.\`lastName\`) AS \`actFullName\`
    FROM
        (((((((((((((((\`posMasterAct\`
        JOIN \`posMaster\` \`posMasterChild\` ON ((\`posMasterAct\`.\`posMasterChildId\` = \`posMasterChild\`.\`id\`)))
        JOIN \`profile\` \`profileChild\` ON ((\`posMasterChild\`.\`current_holderId\` = \`profileChild\`.\`id\`)))
        LEFT JOIN \`orgRoot\` \`orgRootChild\` ON ((\`posMasterChild\`.\`orgRootId\` = \`orgRootChild\`.\`id\`)))
        LEFT JOIN \`orgChild1\` \`orgChild1Child\` ON ((\`posMasterChild\`.\`orgChild1Id\` = \`orgChild1Child\`.\`id\`)))
        LEFT JOIN \`orgChild2\` \`orgChild2Child\` ON ((\`posMasterChild\`.\`orgChild2Id\` = \`orgChild2Child\`.\`id\`)))
        LEFT JOIN \`orgChild3\` \`orgChild3Child\` ON ((\`posMasterChild\`.\`orgChild3Id\` = \`orgChild3Child\`.\`id\`)))
        LEFT JOIN \`orgChild4\` \`orgChild4Child\` ON ((\`posMasterChild\`.\`orgChild4Id\` = \`orgChild4Child\`.\`id\`)))
        JOIN \`posLevel\` ON ((\`profileChild\`.\`posLevelId\` = \`posLevel\`.\`id\`)))
        JOIN \`posType\` ON ((\`profileChild\`.\`posTypeId\` = \`posType\`.\`id\`)))
        JOIN \`posMaster\` ON ((\`posMasterAct\`.\`posMasterId\` = \`posMaster\`.\`id\`)))
        LEFT JOIN \`orgRoot\` ON ((\`posMaster\`.\`orgRootId\` = \`orgRoot\`.\`id\`)))
        LEFT JOIN \`orgChild1\` ON ((\`posMaster\`.\`orgChild1Id\` = \`orgChild1\`.\`id\`)))
        JOIN \`profile\` ON ((\`posMaster\`.\`current_holderId\` = \`profile\`.\`id\`)))
        LEFT JOIN \`position\` ON ((\`posMasterChild\`.\`id\` = \`position\`.\`posMasterId\`)))
        LEFT JOIN \`posExecutive\` ON ((\`position\`.\`posExecutiveId\` = \`posExecutive\`.\`id\`)))
    WHERE
        (\`position\`.\`positionIsSelected\` = TRUE)`,
})
export class viewDirectorActing {
  @ViewColumn()
  keycloakId: string;
  @ViewColumn()
  id: string;
  @ViewColumn()
  prefix: string;
  @ViewColumn()
  firstName: string;
  @ViewColumn()
  lastName: string;
  @ViewColumn()
  citizenId: string;
  @ViewColumn()
  position: string;
  @ViewColumn()
  isProbation: string;
  @ViewColumn()
  posNo: string;
  @ViewColumn()
  posNoAct: string;
  @ViewColumn()
  posLevel: string;
  @ViewColumn()
  posType: string;
  @ViewColumn()
  posExecutiveName: string;
  @ViewColumn()
  isDirector: boolean;
  @ViewColumn()
  isDeputy: boolean;
  @ViewColumn()
  isOfficer: boolean;
  @ViewColumn()
  isDirectorChild: boolean;
  @ViewColumn()
  orgRevisionId: string;
  @ViewColumn()
  orgRootId: string;
  @ViewColumn()
  orgChild1Id: string;
  @ViewColumn()
  orgChild2Id: string;
  @ViewColumn()
  orgChild3Id: string;
  @ViewColumn()
  orgChild4Id: string;
  @ViewColumn()
  orgRoot: string;
  @ViewColumn()
  orgChild1: string;
  @ViewColumn()
  orgChild2: string;
  @ViewColumn()
  orgChild3: string;
  @ViewColumn()
  orgChild4: string;
  @ViewColumn()
  actFullNameId: string;
  @ViewColumn()
  actFullNameKeycloakId: string;
  @ViewColumn()
  actFullName: string;
  @ViewColumn()
  key: string;
  @ViewColumn()
  positionSign: string;
  @ViewColumn()
  positionSignChild: string;
}
