<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
-->

<services xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="https://ofbiz.apache.org/dtds/services.xsd">
    <description>OFBiz BIRT Services</description>
    <vendor>OFBiz</vendor>
    <version>1.0</version>

    <!--BIRT Email Services -->
    <service name="sendBirtMail" engine="java" location="org.apache.ofbiz.birt.email.BirtEmailServices" invoke="sendBirtMail">
        <description>BIRT Email Service</description>
        <implements service="sendMailInterface"/>
        <attribute name="bodyText" type="String" mode="IN" optional="true"/>
        <attribute name="bodyScreenUri" type="String" mode="IN" optional="true"/>
        <attribute name="birtReportLocation" type="String" mode="IN" optional="false"/>
        <attribute name="attachmentName" type="String" mode="IN" optional="false"/>
        <attribute name="bodyParameters" type="Map" mode="IN" optional="true"/>
        <attribute name="birtParameters" type="Map" mode="IN" optional="true"/>
        <attribute name="birtLocale" type="Locale" mode="IN" optional="true"/>
        <attribute name="birtContentType" type="String" mode="IN" optional="true"/>
        <attribute name="webSiteId" type="String" mode="IN" optional="true"/>
        <attribute name="body" type="String" mode="OUT" optional="false"/>
    </service>

    <!-- SERVICES FOR REPORTS -->
    <service name="genericBirtPermission" engine="simple" auth="true"
            location="component://birt/minilang/BirtPermissionServices.xml" invoke="genericBirtPermission">
        <description>Generic Birt Permission Service; Takes mainAction to determine the mode.</description>
        <implements service="permissionInterface"/>
    </service>

    <!-- Interfaces -->
    <service name="createFlexibleReportFromMasterInterface" engine="interface">
        <attribute name="reportName" type="String" mode="IN" optional="false" />
        <attribute name="description" type="String" mode="IN" optional="true" />
        <attribute name="writeFilters" type="String" mode="IN" optional="true" />
        <attribute name="masterContentId" type="String" mode="IN" optional="false" />
        <attribute name="contentId" type="String" mode="OUT" optional="false" />
    </service>
    <service name="prepareFieldsForFlexibleReportInterface" engine="interface">
        <attribute name="dataMap" type="Map" mode="OUT" optional="false" />
        <attribute name="fieldDisplayLabels" type="Map" mode="OUT" optional="true"/>
        <attribute name="filterMap" type="Map" mode="OUT" optional="true" />
        <attribute name="filterDisplayLabels" type="Map" mode="OUT" optional="true"/>
    </service>
    <service name="searchRecordsForFlexibleReportInterface" engine="interface">
        <attribute name="reportContext" type="Object" mode="IN" optional="false" />
        <attribute name="records" type="List" mode="OUT" />
    </service>

    <service name="createFlexibleReport" engine="java" auth="true" location="org.apache.ofbiz.birt.flexible.BirtServices" invoke="createFlexibleReport">
        <description>BIRT report generation</description>
        <required-permissions join-type="AND"><check-permission permission="BIRT_CREATE"/></required-permissions>
        <attribute name="dataMap" type="Map" mode="IN" optional="false" />
        <attribute name="fieldDisplayLabels" type="Map" mode="IN" optional="true" />
        <attribute name="filterMap" type="Map" mode="IN" optional="true" />
        <attribute name="filterDisplayLabels" type="Map" mode="IN" optional="true" />
        <attribute name="writeFilters" type="String" mode="IN" optional="true" />
        <attribute name="serviceName" type="String" mode="IN" optional="false" />
        <attribute name="rptDesignName" type="String" mode="IN" optional="false" />
    </service>

    <service name="createFlexibleReportFromMaster" auth="true" engine="java" location="org.apache.ofbiz.birt.flexible.BirtServices" invoke="createFlexibleReportFromMaster">
        <description>Call report generator with appropriate workflow required by the given master report</description>
        <required-permissions join-type="AND"><check-permission permission="BIRT_CREATE"/></required-permissions>
        <attribute name="contentId" type="String" mode="IN" optional="false" />
        <attribute name="reportName" type="String" mode="IN" optional="false" />
        <attribute name="description" type="String" mode="IN" optional="false" />
        <attribute name="writeFilters" type="String" mode="IN" optional="true" />
        <attribute name="reportContentId" type="String" mode="OUT" optional="false"/>
        <attribute name="textForm" type="String" mode="OUT" optional="false" allow-html="any"/>
    </service>
    <service name="createFlexibleReportFromMasterEntityWorkflow" engine="java" location="org.apache.ofbiz.birt.flexible.BirtServices" invoke="createFlexibleReportFromMasterEntityWorkflow">
        <description>Create and save in db content, a new report design following entity workflow</description>
        <required-permissions join-type="AND"><check-permission permission="BIRT_CREATE"/></required-permissions>
        <implements service="createFlexibleReportFromMasterInterface"/>
        <attribute name="entityViewName" type="String" mode="IN" optional="false" />
    </service>
    <service name="createFlexibleReportFromMasterServiceWorkflow" engine="java" location="org.apache.ofbiz.birt.flexible.BirtServices" invoke="createFlexibleReportFromMasterServiceWorkflow">
        <description>Create and save in db content, a new report following service workflow</description>
        <required-permissions join-type="AND"><check-permission permission="BIRT_CREATE"/></required-permissions>
        <implements service="createFlexibleReportFromMasterInterface"/>
        <attribute name="serviceName" type="String" mode="IN" optional="false" />
    </service>
    <service name="deleteAllFlexibleReports" auth="true" engine="java" location="org.apache.ofbiz.birt.flexible.BirtServices" invoke="deleteAllReports">
        <description>Delete all reports (admin purposes)</description>
        <required-permissions join-type="AND"><check-permission permission="BIRT_DELETE"/></required-permissions>
    </service>
    <service name="deleteFlexibleReport" auth="true" engine="java" location="org.apache.ofbiz.birt.flexible.BirtServices" invoke="deleteFlexibleReport">
        <description>Delete a report</description>
        <required-permissions join-type="AND"><check-permission permission="BIRT_DELETE"/></required-permissions>
        <attribute name="contentId" type="String" mode="IN" optional="false" />
    </service>

    <service name="prepareFlexibleReportOptionFieldsFromEntity" engine="java" location="org.apache.ofbiz.birt.flexible.BirtServices" invoke="prepareFlexibleReportOptionFieldsFromEntity">
        <description>Get fields corresponding to an entity or view, including _op _value and so on depending on type.</description>
        <required-permissions join-type="AND"><check-permission permission="BIRT_CREATE"/></required-permissions>
        <attribute name="entityViewName" type="String" mode="IN" optional="false" />
        <attribute name="listMultiFields" type="List" mode="OUT" optional="false" />
    </service>
    <service name="prepareFlexibleReportFieldsFromEntity" engine="java" location="org.apache.ofbiz.birt.flexible.BirtServices" invoke="prepareFlexibleReportFieldsFromEntity">
        <description>prepare maps fields for ReportDesignGenerator</description>
        <required-permissions join-type="AND"><check-permission permission="BIRT_CREATE"/></required-permissions>
        <implements service="prepareFieldsForFlexibleReportInterface"/>
        <attribute name="modelEntity" mode="IN" type="Object"/>
    </service>

    <service name="uploadFlexibleReportRptDesign" auth="true" engine="java" location="org.apache.ofbiz.birt.flexible.BirtServices" invoke="uploadRptDesign">
        <description>Upload design-modified rptdesign file</description>
        <required-permissions join-type="AND"><check-permission permission="BIRT_UPDATE"/></required-permissions>
        <attribute name="dataResourceIdRpt" type="String" mode="IN" optional="false" />
        <attribute name="uploadRptDesign" type="java.nio.ByteBuffer" mode="IN" optional="false" />
    </service>

    <service name="updateFlexibleReportSearchForm" auth="true" engine="java" location="org.apache.ofbiz.birt.flexible.BirtServices" invoke="overrideReportForm">
        <description>Override report form</description>
        <required-permissions join-type="OR">
            <check-permission permission="BIRT_CREATE"/>
            <check-permission permission="BIRT_UPDATE"/>
        </required-permissions>
        <attribute name="reportContentId" type="String" mode="IN" optional="false" />
        <attribute name="overrideFilters" type="String" mode="IN" optional="true" allow-html="any"/>
    </service>
    <service name="prepareFlexibleReportSearchFormToEdit" auth="true" engine="java" location="org.apache.ofbiz.birt.flexible.BirtServices" invoke="createFormForDisplay">
        <description>Prepare from DB report form for display</description>
        <required-permissions join-type="OR">
            <check-permission permission="BIRT_CREATE"/>
            <check-permission permission="BIRT_UPDATE"/>
        </required-permissions>
        <attribute name="reportContentId" type="String" mode="IN" optional="false" />
        <attribute name="textForm" type="String" mode="OUT" optional="false" allow-html="any"/>
    </service>

    <!-- Service example for flexible report-->
    <service name="callPerformFindFromBirt" engine="java" auth="true" location="org.apache.ofbiz.birt.flexible.BirtServices" invoke="callPerformFindFromBirt" transaction-timeout="7200">
        <description>Manages performFind calling from Birt. Flexible Report from entity workflow. (Default search service)</description>
        <required-permissions join-type="AND"><check-permission permission="BIRT_VIEW"/></required-permissions>
        <implements service="searchRecordsForFlexibleReportInterface"/>
    </service>
    <service name="flexibleReportTurnOver" auth="true" engine="java" location="org.apache.ofbiz.birt.flexible.BirtMasterReportServices" invoke="turnOver">
        <description>Service getting data for report. Turnover report</description>
        <implements service="searchRecordsForFlexibleReportInterface"/>
    </service>
    <service name="flexibleReportTurnOverPrepareFields" auth="true" engine="java" location="org.apache.ofbiz.birt.flexible.BirtMasterReportServices" invoke="turnOverPrepareFields">
        <description>Service configuring data for report (works in duo!). Turnover report.</description>
        <implements service="prepareFieldsForFlexibleReportInterface"/>
    </service>
</services>
