Skip to content

Commit

Permalink
Merge branch 'moqui:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
dixitdeepak authored Apr 20, 2022
2 parents c99ea9b + 3e5ad8b commit 81ed1f0
Show file tree
Hide file tree
Showing 21 changed files with 375 additions and 65 deletions.
7 changes: 6 additions & 1 deletion base-component/tools/screen/Tools/AutoScreen/AutoFind.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ along with this software (see the LICENSE.md file). If not, see

<transition name="list"><default-response url="../MainEntityList"/></transition>
<transition name="find"><default-response url="."/></transition>
<transition name="entityDetail"><default-response url="../../Entity/DataEdit/EntityDetail"/></transition>

<transition name="create"><actions><service-call name="create#${aen}" in-map="true"/></actions>
<default-response url="."/></transition>
<transition name="deleteRecord"><actions><service-call name="delete#${aen}" in-map="context"/></actions>
Expand Down Expand Up @@ -52,20 +54,23 @@ along with this software (see the LICENSE.md file). If not, see
<widgets>
<container>
<link url="list" text="Entity List" link-type="hidden-form"/>
<container-dialog id="FindValueDialog" button-text="Find ${ec.entity.getEntityDefinition(aen).getPrettyName(null, null)}" width="800">
<container-dialog id="FindValueDialog" button-text="Find Options" width="800">
<form-single name="FindEntityValue" transition="find" dynamic="true">
<auto-fields-entity entity-name="${aen}" field-type="find"/>
<field name="aen"><default-field><hidden/></default-field></field>
<field name="submitButton"><default-field title="Find"><submit/></default-field></field>
</form-single>
</container-dialog>
<link url="entityDetail" parameter-map="[selectedEntity:aen]" text="Entity Detail"/>
<container-dialog id="CreateValueDialog" button-text="New Value">
<form-single name="CreateEntityValue" transition="create" dynamic="true">
<auto-fields-entity entity-name="${aen}" field-type="edit"/>
<field name="aen"><default-field><hidden/></default-field></field>
<field name="submitButton"><default-field title="Create"><submit/></default-field></field>
</form-single>
</container-dialog>

<label text="Find ${aenDef.getPrettyName(null, null)}" type="strong"/>
</container>
<form-list name="ListEntityValue" list="entityValueList" list-entry="entityValue" header-dialog="true" skip-form="true" dynamic="true"
show-csv-button="true" show-xlsx-button="true" show-page-size="true">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,23 @@ along with this software (see the LICENSE.md file). If not, see
<widgets>
<container>
<link url="list" text="Entity List"/>
<container-dialog id="FindValueDialog" button-text="Find">
<container-dialog id="FindValueDialog" button-text="Find Options">
<form-single name="FindEntityValue" transition="find" dynamic="true">
<auto-fields-entity entity-name="${selectedEntity}" field-type="find"/>
<field name="selectedEntity"><default-field title="Entity Name"><hidden/></default-field></field>
<field name="submitButton"><default-field title="Find"><submit/></default-field></field>
</form-single>
</container-dialog>
<link url="../EntityDetail" parameter-map="[selectedEntity:selectedEntity]" text="Entity Detail"/>
<container-dialog id="CreateValueDialog" button-text="New Value">
<form-single name="CreateEntityValue" transition="create" dynamic="true">
<auto-fields-entity entity-name="${selectedEntity}" field-type="edit"/>
<field name="selectedEntity"><default-field title="Entity Name"><hidden/></default-field></field>
<field name="submitButton"><default-field title="Create"><submit/></default-field></field>
</form-single>
</container-dialog>
<link url="../EntityDetail" parameter-map="[selectedEntity:selectedEntity]" text="See Entity Detail"/>
</container>
<container><label text="Find '${selectedEntity}' Entity Value" type="h3"/></container>
<container><label text="Find ${entityDefinition.getPrettyName(null, null)} (${selectedEntity})" type="h3"/></container>
<form-list name="ListEntityValue" list="entityValueList" transition="listSubmit" header-dialog="true" dynamic="true"
show-csv-button="true" show-xlsx-button="true" show-page-size="true">
<hidden-parameters><parameter name="selectedEntity"/></hidden-parameters>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ along with this software (see the LICENSE.md file). If not, see

<transition name="list"><default-response url="../EntityList"/></transition>
<transition name="find"><default-response url="../EntityDataFind"/></transition>
<transition name="autoFind"><default-response url="../../../AutoScreen/AutoFind"/></transition>
<transition name="checkTable">
<actions><script>ec.entity.entityDbMeta.forceCheckTableRuntime(ec.entity.getEntityDefinition(selectedEntity))</script></actions>
<default-response url="."/>
Expand All @@ -47,10 +48,11 @@ along with this software (see the LICENSE.md file). If not, see
<widgets>
<container>
<link url="list" text="Entity List"/>
<link url="find" text="Find ${entityDefinition.entityName}"/>
<link url="find" text="Entity Find"/>
<link url="autoFind" text="Auto Screen Find" parameter-map="[aen:selectedEntity]"/>
<link url="checkTable" text="Check/Update Table" tooltip="Check and update DB table from entity definition"/>
</container>
<container><label text="Entity Detail for '${entityDefinition.fullEntityName}'" type="h3"/></container>
<container><label text="Entity Detail for ${entityDefinition.getPrettyName(null, null)} (${entityDefinition.fullEntityName})" type="h3"/></container>
<container-row>
<row-col md="3"><label text="View Entity? ${entityDefinition.isViewEntity}" type="strong"/></row-col>
<row-col md="3"><label text="Short Alias: ${entityInfo.shortAlias ?: 'N/A'}" type="strong"/></row-col>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ along with this software (see the LICENSE.md file). If not, see
<field name="find"><default-field>
<link url="find" text="Find" link-type="anchor" parameter-map="[selectedEntity:fullEntityName]"/>
</default-field></field>
<field name="detail"><default-field>
<link url="detail" text="Detail" link-type="anchor" parameter-map="[selectedEntity:fullEntityName]"/>
</default-field></field>
<field name="autoScreen"><default-field>
<link url="autoScreen" text="Auto Screen" link-type="anchor" parameter-map="[aen:fullEntityName]"/>
</default-field></field>
<field name="detail"><default-field>
<link url="detail" text="Detail" link-type="anchor" parameter-map="[selectedEntity:fullEntityName]"/>
</default-field></field>
</form-list>
</widgets>
</screen>
30 changes: 27 additions & 3 deletions base-component/tools/screen/Tools/Entity/DataExport.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ along with this software (see the LICENSE.md file). If not, see
return
}
if (entityNames instanceof String && entityNames.contains(",")) {
if (entityNames.startsWith("[")) entityNames = entityNames.substring(1)
if (entityNames.endsWith("]")) entityNames = entityNames.substring(0, entityNames.length() - 1)
entityNames = entityNames.split(",") as List
}
if (entityNames instanceof List) {
for (String entityName in entityNames) {
def entDef = ec.entity.getEntityDefinition(entityName)
Expand All @@ -50,6 +56,7 @@ along with this software (see the LICENSE.md file). If not, see
if (filterMap) edw.filterMap((Map) ec.resource.expression(filterMap, null))
if (orderBy) edw.orderBy([(String) orderBy])
edw.fileType((String) fileType)
if(fileType == 'CSV') edw.tableColumnNames(useTableColumnNames == 'Yes' ? true : false)
noResponse = false
if (context.output == "file") {
Expand All @@ -59,11 +66,23 @@ along with this software (see the LICENSE.md file). If not, see
} else if (context.output == "browser") {
// stream to ec.web.response
def response = ec.web.response
response.setContentType(fileType == 'JSON' ? 'application/json' : 'text/xml')
response.setCharacterEncoding("UTF-8")
response.setHeader("Content-Disposition", "attachment; filename=\"EntityExport_${ec.l10n.format(ec.user.nowTimestamp, 'yyyyMMdd_HHmm')}.${fileType == 'JSON' ? 'json' : 'xml'}\";")
response.setHeader("Cache-Control", "no-cache, must-revalidate, private")
edw.writer(response.getWriter())
if (fileType == 'CSV' && entityNames instanceof List && entityNames.size() > 1) {
// if trying to export more than one entity as CSV, send a .zip file instead
response.setContentType('application/zip')
response.setHeader("Content-Disposition", "attachment; filename=\"EntityExport_${ec.l10n.format(ec.user.nowTimestamp, 'yyyyMMdd_HHmm')}.zip\";")
edw.zipDirectory('', response.getOutputStream())
} else {
if (fileType == 'JSON') response.setContentType('application/json')
else if (fileType == 'CSV') response.setContentType('text/csv')
else response.setContentType('text/xml')
response.setHeader("Content-Disposition", "attachment; filename=\"EntityExport_${ec.l10n.format(ec.user.nowTimestamp, 'yyyyMMdd_HHmm')}.${fileType == 'JSON' ? 'json' : fileType == 'CSV' ? 'csv' : 'xml'}\";")
edw.writer(response.getWriter())
}
noResponse = true
}
]]></script>
Expand Down Expand Up @@ -91,6 +110,11 @@ along with this software (see the LICENSE.md file). If not, see
<field name="fileType"><default-field>
<radio no-current-selected-key="XML"><option key="XML"/><option key="JSON"/><option key="CSV"/></radio>
</default-field></field>
<field name="useTableColumnNames">
<default-field title="Use Table Column Names (CSV Only)">
<radio no-current-selected-key="No"><option key="No"/><option key="Yes"/></radio>
</default-field>
</field>
<field name="output">
<default-field><radio no-current-selected-key="browser">
<option key="file" text="Single File"/>
Expand Down
25 changes: 14 additions & 11 deletions base-component/tools/screen/Tools/Entity/DataSnapshot.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ along with this software (see the LICENSE.md file). If not, see
<transition name="exportSnapshot" begin-transaction="false">
<actions>
<script><![CDATA[
if (!entitiesToInclude) entitiesToInclude = null
if (entitiesToInclude != null && !(entitiesToInclude instanceof List)) entitiesToInclude = [entitiesToInclude]
if (!entitiesToSkip) entitiesToSkip = null
if (entitiesToSkip != null && !(entitiesToSkip instanceof List)) entitiesToSkip = [entitiesToSkip]
if ("CSV".equals(fileType)) filePerEntity = true
jobRunId = ec.service.job("ExportEntityDataSnapshot")
.parameters([fromDate:fromDate, thruDate:thruDate, baseFilename:baseFilename, fileType:fileType,
filePerEntity:filePerEntity, isoDateTime:isoDateTime, tableColumnNames:tableColumnNames,
entitiesToSkip:entitiesToSkip]).run()
entitiesToSkip:entitiesToSkip, entitiesToInclude:entitiesToInclude]).run()
]]></script>
<message>Started Export Entity Data Snapshot ${baseFilename} (Job ID ${jobRunId})</message>
</actions>
Expand Down Expand Up @@ -86,12 +88,15 @@ along with this software (see the LICENSE.md file). If not, see
<widgets>
<container-dialog id="ExportDialog" button-text="Export Snapshot">
<form-single name="ExportData" transition="exportSnapshot">
<!-- NOTE: add entities to exclude?, maybe ArtifactHit by default? -->
<field name="entitiesToSkip">
<default-field><drop-down allow-multiple="true" size="80">
<field name="entitiesToInclude"><default-field tooltip="Defaults to include all if none selected and one or more skip entities specified">
<drop-down allow-multiple="true" size="80">
<list-options list="ec.entity.getAllEntitiesInfo('fullEntityName', null, false, true)" key="${fullEntityName}"/>
</drop-down></default-field>
</field>
</drop-down>
</default-field></field>
<!-- NOTE: add sets of entities to exclude? maybe ArtifactHit by default? -->
<field name="entitiesToSkip"><default-field><drop-down allow-multiple="true" size="80">
<list-options list="ec.entity.getAllEntitiesInfo('fullEntityName', null, false, true)" key="${fullEntityName}"/>
</drop-down></default-field></field>
<field name="fromDate"><default-field><date-time minute-stepping="1"/></default-field></field>
<field name="thruDate"><default-field><date-time minute-stepping="1"/></default-field></field>
<field name="baseFilename"><default-field><text-line size="40" default-value="MoquiSnapshot-${ec.l10n.format(ec.user.nowTimestamp, 'yyyyMMdd-HHmm')}"/></default-field></field>
Expand All @@ -101,14 +106,12 @@ along with this software (see the LICENSE.md file). If not, see
<field name="filePerEntity"><default-field>
<radio no-current-selected-key="false"><option key="true"/><option key="false"/></radio>
</default-field></field>
<!-- these are only supported for CSV for now, hide until better supported (ie API only)
<field name="isoDateTime"><default-field>
<field name="isoDateTime"><default-field title="ISO Date Time" tooltip="CSV ONLY">
<radio no-current-selected-key="false"><option key="true"/><option key="false"/></radio>
</default-field></field>
<field name="tableColumnNames"><default-field>
<field name="tableColumnNames"><default-field tooltip="CSV ONLY, use table and column names instead of entity and field names">
<radio no-current-selected-key="false"><option key="true"/><option key="false"/></radio>
</default-field></field>
-->
<field name="submitButton"><default-field title="Export Snapshot"><submit/></default-field></field>
</form-single>
</container-dialog>
Expand All @@ -128,7 +131,7 @@ along with this software (see the LICENSE.md file). If not, see
<row-col sm="2"><label text="${ec.l10n.format(new java.sql.Timestamp(sfile.lastModified()), null)}"/></row-col>
<row-col sm="2"><label text="${ec.l10n.format((sfile.length())/(1024*1024), '#,##0.00')} MiB"/></row-col>
<row-col sm="1"><link url="downloadSnapshot" text="Download" parameter-map="[filename:sfile.name]"/></row-col>
<row-col sm="1"><link url="deleteSnapshot" text="Delete" parameter-map="[filename:sfile.name]"/></row-col>
<row-col sm="1"><link url="deleteSnapshot" text="Delete" parameter-map="[filename:sfile.name]" confirmation="Really delete ${sfile.name}?"/></row-col>
<row-col sm="1"><container-dialog id="ImportDialog" button-text="Import">
<form-single name="ImportForm" transition="importSnapshot">
<field name="zipFilename" from="sfile.name"><default-field><display/></default-field></field>
Expand Down
4 changes: 3 additions & 1 deletion base-component/tools/screen/Tools/Entity/SqlRunner.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ along with this software (see the LICENSE.md file). If not, see
<http://creativecommons.org/publicdomain/zero/1.0/>.
-->
<screen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://moqui.org/xsd/xml-screen-2.1.xsd"
default-menu-title="SQL" begin-transaction="false"><!-- NOTE: begin tx is false so table meta data changes, etc can be done -->
default-menu-title="SQL Runner" begin-transaction="false"><!-- NOTE: begin tx is false so table meta data changes, etc can be done -->

<actions>
<if condition="!ec.user.hasPermission('SQL_RUNNER_WEB')">
<return error="true" message="User does not have permission to use the SQL Runner"/></if>
<if condition="!sri.getScreenUrlInfo().isPermitted(ec, null, org.moqui.context.ArtifactExecutionInfo.AUTHZA_ALL)">
<return error="true" message="User must be authorized for all actions on this screen"/></if>

Expand Down
Loading

0 comments on commit 81ed1f0

Please sign in to comment.