Разработать календарь для отображения поручений

Инструмент: Палитра XML

Статус

РазделПредставления
Комментарий



Создание представления


В календаре показываются только колонки с определенным названием:

  • self - определяется в бине коллекции как объект класса BuildVirtualField через id, created_date и т.д.
  • subject - заголовок или что-то другое подходящее по смыслу
  • taskDueDate - дата события
  • taskType - доп. информация, например тип события

Кастомная коллекция

Кастомная коллекция представляет собой набор 2-х файлов:

<collection name="Tasks_(vw_cmj_calendar)" idField="id" replace="runtime">
    <prototype>
        <![CDATA[
SELECT
    id,
    created_date,
    Module,
    self_1,
    self_2,
    self_3,
    taskDueDate,
    subject,
    executors as taskExecutor
FROM(
        SELECT
            resolution.id AS id,
            rkkbase.created_date,
            rkkbase.module AS Module,
            '<id>' AS self_1,
            ':' AS self_2,
            '</>' AS self_3,

			(case
				when resolution.CtrlDeadline is null then now()
				when resolution.CtrlDeadline = '0001-01-01 00:00:00.000' then now()
				else resolution.CtrlDeadline
				end) as taskDueDate,

			resolution.resolution as subject,

            (
                SELECT
                    DISTINCT coalesce(
                                     string_agg(
                                                                         '<id>' || substring(unid, 33, 48) || ':' || substring(unid, 1, 32)
                                                             || '</><shortName>' || sname|| '</>'
                                         , ','),
                                     '<id></><shortName></>'
                                 )

                FROM(
                        SELECT
                            execbeard.cmjunid as unid,
                            execbeard.Orig_ShortName as sname
                        FROM
                            F_DP_TasksResolution_ec resexec
                                LEFT JOIN so_beard execbeard ON execbeard.id = resexec.executorcurr
                        WHERE
                                resexec.owner = resolution.id AND resexec.idx = 0
                        UNION
                        SELECT
                            execbeard.cmjunid as unid,
                            execbeard.Orig_ShortName as sname
                        FROM
                            F_DP_TasksResolution_EE resexec
                                LEFT JOIN so_beard execbeard ON execbeard.id = resexec.executorext
                        WHERE
                                resexec.owner = resolution.id AND resexec.idx = 0
                    ) q
            )                                        AS executors

        FROM f_dp_tasksresolution resolution
                 LEFT JOIN f_dp_rkkbase rkkbase ON rkkbase.id = resolution.id
                 LEFT JOIN SO_Beard execbeard ON execbeard.id = resolution.author

                 LEFT JOIN (SELECT soapp.id                          AS id,
                                    soapp.id_type                     AS id_type,
                                    soapp.beard                       AS beard,
                                    soapp.beard_type                  AS beard_type,
                                    CASE
                                        WHEN soapp_plain.id IS NOT NULL THEN soapp_plain.post
                                        ELSE soapp_head.post END      AS post,
                                    CASE
                                        WHEN soapp_plain.id IS NOT NULL THEN soapp_plain.post_type
                                        ELSE soapp_head.post_type END AS post_type
                             FROM so_appointment soapp
                                      LEFT JOIN so_appointmentplain soapp_plain
                                                ON soapp.id = soapp_plain.id AND
                                                   soapp.id_type = soapp_plain.id_type
                                      LEFT JOIN so_appointmenthead soapp_head
                                                ON soapp.id = soapp_head.id AND
                                                   soapp.id_type = soapp_head.id_type) author_app
                            ON execbeard.id = author_app.beard AND
                               execbeard.id_type = author_app.beard_type
                 LEFT JOIN so_post author_post
                            ON author_app.post = author_post.id AND
                               author_app.post_type = author_post.id_type
        WHERE rkkbase.isdeleted != 1 AND resolution.ctrlDateExecution IS NULL

    )s WHERE
        1=1
             ::where-clause
            ]]>
    </prototype>
    <counting-prototype>
        <![CDATA[
                SELECT
                    COUNT(*)
FROM(
        SELECT
            resolution.id AS id,
            rkkbase.created_date,
            rkkbase.module AS Module,
            '<id>' AS self_1,
            ':' AS self_2,
            '</>' AS self_3,

			(case
				when resolution.CtrlDeadline is null then now()
				when resolution.CtrlDeadline = '0001-01-01 00:00:00.000' then now()
				else resolution.CtrlDeadline
				end) as taskDueDate,

			resolution.resolution as subject,

            (
                SELECT
                    DISTINCT coalesce(
                                     string_agg(
                                                                         '<id>' || substring(unid, 33, 48) || ':' || substring(unid, 1, 32)
                                                             || '</><shortName>' || sname|| '</>'
                                         , ','),
                                     '<id></><shortName></>'
                                 )

                FROM(
                        SELECT
                            execbeard.cmjunid as unid,
                            execbeard.Orig_ShortName as sname
                        FROM
                            F_DP_TasksResolution_ec resexec
                                LEFT JOIN so_beard execbeard ON execbeard.id = resexec.executorcurr
                        WHERE
                                resexec.owner = resolution.id AND resexec.idx = 0
                        UNION
                        SELECT
                            execbeard.cmjunid as unid,
                            execbeard.Orig_ShortName as sname
                        FROM
                            F_DP_TasksResolution_EE resexec
                                LEFT JOIN so_beard execbeard ON execbeard.id = resexec.executorext
                        WHERE
                                resexec.owner = resolution.id AND resexec.idx = 0
                    ) q
            )                                        AS executors

        FROM f_dp_tasksresolution resolution
                 LEFT JOIN f_dp_rkkbase rkkbase ON rkkbase.id = resolution.id
                 LEFT JOIN SO_Beard execbeard ON execbeard.id = resolution.author

                 LEFT JOIN (SELECT soapp.id                          AS id,
                                    soapp.id_type                     AS id_type,
                                    soapp.beard                       AS beard,
                                    soapp.beard_type                  AS beard_type,
                                    CASE
                                        WHEN soapp_plain.id IS NOT NULL THEN soapp_plain.post
                                        ELSE soapp_head.post END      AS post,
                                    CASE
                                        WHEN soapp_plain.id IS NOT NULL THEN soapp_plain.post_type
                                        ELSE soapp_head.post_type END AS post_type
                             FROM so_appointment soapp
                                      LEFT JOIN so_appointmentplain soapp_plain
                                                ON soapp.id = soapp_plain.id AND
                                                   soapp.id_type = soapp_plain.id_type
                                      LEFT JOIN so_appointmenthead soapp_head
                                                ON soapp.id = soapp_head.id AND
                                                   soapp.id_type = soapp_head.id_type) author_app
                            ON execbeard.id = author_app.beard AND
                               execbeard.id_type = author_app.beard_type
                 LEFT JOIN so_post author_post
                            ON author_app.post = author_post.id AND
                               author_app.post_type = author_post.id_type
        WHERE rkkbase.isdeleted != 1 AND resolution.ctrlDateExecution IS NULL

    )s WHERE
        1=1
                    ::where-clause
            ]]>
    </counting-prototype>
    <filter name="MODULE">
        <criteria placeholder="where-clause">
            <![CDATA[
                    Module = {0}
                ]]>
        </criteria>
    </filter>
    <filter name="created_date_partial"> <!-- Функционал фильра другой, но называть их по как хочется не разрешает схема валидации -->
        <criteria placeholder="where-clause">
            <![CDATA[
                     ('б/д' ilike '%'||{0}||'%' and (created_date is null))
                ]]>
        </criteria>
    </filter>
    <filter name="created_date">
        <criteria placeholder="where-clause">
            <![CDATA[
                    cast(created_date as date) = cast({0} as date)
                ]]>
        </criteria>
    </filter>
    <filter name="taskDueDate_partial">
        <criteria placeholder="where-clause">
            <![CDATA[
                     (taskDueDate BETWEEN {0} AND {1})
                ]]>
        </criteria>
    </filter>
    <filter name="taskDueDate">
        <criteria placeholder="where-clause">
            <![CDATA[
                    (taskDueDate BETWEEN {0} AND {1})
                ]]>
        </criteria>
    </filter>
    <filter name="taskDueDate_GE">
        <criteria placeholder="where-clause">
            <![CDATA[
                    taskDueDate >= {0}
                ]]>
        </criteria>
    </filter>
    <filter name="taskDueDate_L">
        <criteria placeholder="where-clause">
            <![CDATA[
                    taskDueDate < {0}
                ]]>
        </criteria>
    </filter>
    <filter name="self">
        <criteria placeholder="where-clause">
            <![CDATA[
                    Module = {0} and id = {1}
                ]]>
        </criteria>
    </filter>
    <filter name="subject">
        <criteria placeholder="where-clause">
            <![CDATA[
                    subject = {0}
                ]]>
        </criteria>
    </filter>
    <filter name="subject_partial">
        <criteria placeholder="where-clause">
            <![CDATA[
                    subject iLIKE ('%'||{0}||'%')
                ]]>
        </criteria>
    </filter>
    <filter name="personUnid">
        <criteria placeholder="where-clause">
            <![CDATA[
                	cast(substring({0}, 5, 12) AS INT) = personUnid
                ]]>
        </criteria>
    </filter>
    <filter name="personUnid_partial">
        <criteria placeholder="where-clause">
            <![CDATA[
                    cast(substring({0}, 5, 12) AS INT) = personUnid
                ]]>
        </criteria>
    </filter>
</collection>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"
       default-lazy-init="true">


    <bean id="Tasks_(vw_cmj_calendar)Metadata"
          class="ru.intertrust.cm_sochi.srv.connector.sochi.collections.CollectionMetadataNew"
          p:caseSensitiveFieldNames="true" p:searchArea="Tasks">
        <constructor-arg>
            <list value-type="ru.intertrust.cm_sochi.srv.connector.sochi.collections.Field">
                <bean class="ru.intertrust.cm_sochi.srv.connector.sochi.collections.Field" p:name="self">
                    <property name="virtualField">
                        <bean class="ru.intertrust.cm_sochi.srv.connector.sochi.collections.BuildVirtualField">
                            <property name="realFields">
                                <list>
                                    <value>self_1</value>
                                    <value>Module</value>
                                    <value>self_2</value>
                                    <value>ID</value>
                                    <value>created_date</value>
                                    <value>self_3</value>
                                </list>
                            </property>
                            <property name="pattern" value="<id>([0-9]{16}):([0-9A-F]{32})</>"/>
                            <property name="separator" value=""/>
                            <property name="emptySeparator" value="true"/>
                        </bean>
                    </property>
                </bean>
                <bean class="ru.intertrust.cm_sochi.srv.connector.sochi.collections.Field" p:name="taskDueDate" p:filter="taskDueDate" p:sortOrder="ASCENDING" p:sortPriority="0"/>
            </list>
        </constructor-arg>
    </bean>
</beans>

Названия корневого bean должно строиться из названия collection и префикса Metadata. Пример: Tasks_(vw_cmj_calendar)Metadata

Дескриптор

Дескриптор решает следующие задачи:

  1. Связывает колонки с табличными данными
  2. Управляет колонками: категоризация, сортировка, фильтрация, скрытие, важность и т.д.
  3. Определяет по какому алгоритму будут отображаться данные в Web-клиенте, с помощью builder
  4. Связывает с модулем
  5. Подключает кастомные кнопки

<?xml version='1.0' encoding='UTF-8'?>
<catalog xmlns="http://www.intertrust.ru/schema/palette/cat-ui">
  <custom-descriptor ident="Tasks" view="Tasks_(vw_cmj_calendar)" id="dp-tasks-Calendar-AF5" name="Поручения - Календарь AF5" style="calendar">
    <help id="99778671"/>
    <builder name="ru.intertrust.cm_sochi.srv.uicollections.UiBuilder"/>
    <table>
      <columns>
        <column-ref ref="self"/>
        <column-ref ref="subject"/>
        <column-ref ref="taskExecutor"/>
        <column-ref ref="taskDueDate"/>
      </columns>
    </table>
  </custom-descriptor>
</catalog>

Представление

Представление связывает дескриптор с навигационной панелью.

 <view id="tasks-CalendarAF5" name="${catalog.view.tasks-CalendarAF5.name:Исполнение}" position="50">
    <pagename name="Исполнение"/>
    <descriptor-ref ref="dp-tasks-Calendar-AF5"/>
    <source>
       <module ident="Tasks"/>
    </source>
</view>