Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Improved: Convert EntitySyncServices.xml mini-lang to groovy
(OFBIZ-11660)

removed: EntitySyncServices.xml
added: EntitySyncServices.groovy
modified: services.xml to reflect the change from minilang to groovy for:
- entitySyncPermissionCheck
- resetEntitySyncStatus
modified: webtools/controller.xml to reflect changed request-map and event type regarding reset of EntitySyncStatus
modified: webtools/widget/EntitySyncForms.xml to reflect changed target regarding reset of EntitySyncStatus

Thanks: Pierre Smits for implementation
  • Loading branch information
danwatford committed May 30, 2021
1 parent c4b106e commit c654d9b
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 43 deletions.
32 changes: 32 additions & 0 deletions framework/entityext/groovyScripts/EntitySyncServices.groovy
@@ -0,0 +1,32 @@
/*
* 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.
*/

def entitySyncPermissionCheck() {
parameters.primaryPermission = "ENTITY_SYNC"
Map serviceResult = run service: "genericBasePermissionCheck", with: parameters
return serviceResult
}

def resetEntitySyncStatus() {
entitySyncRecord = from("EntitySync").where("entitySyncId", parameters.entitySyncId).queryOne()
if(entitySyncRecord && "ESR_RUNNING".equals(entitySyncRecord.runStatusId)) {
entitySyncRecord.runStatusId = "ESR_NOT_STARTED"
entitySyncRecord.store()
}
}
36 changes: 0 additions & 36 deletions framework/entityext/minilang/EntitySyncServices.xml

This file was deleted.

8 changes: 4 additions & 4 deletions framework/entityext/servicedef/services.xml
Expand Up @@ -224,8 +224,8 @@ under the License.
location="org.apache.ofbiz.entityext.synchronization.EntitySyncServices" invoke="cleanSyncRemoveInfo" auth="true" transaction-timeout="600">
<description>Clean EntitySyncRemove Info - Generally should be run asynchronously after each sync run, or periodically run on a schedule</description>
</service>
<service name="resetEntitySyncStatusToNotStarted" engine="simple"
location="component://entityext/minilang/EntitySyncServices.xml" invoke="resetEntitySyncStatusToNotStarted" auth="true" transaction-timeout="600">
<service name="resetEntitySyncStatus" engine="groovy"
location="component://entityext/groovyScripts/EntitySyncServices.groovy" invoke="resetEntitySyncStatus" auth="true" transaction-timeout="600">
<description>Generally run manually to reset the status of an EntitySync when it has "crashed". Update a EntitySync, set the Status to ESR_NOT_STARTED, but ONLY if running (ie in ESR_RUNNING)</description>
<permission-service service-name="entitySyncPermissionCheck" main-action="UPDATE"/>
<attribute name="entitySyncId" type="String" mode="IN" optional="false"/>
Expand Down Expand Up @@ -446,8 +446,8 @@ under the License.
<description>Delete a ServerHitType</description>
<auto-attributes include="pk" mode="IN" optional="false"/>
</service>
<service name="entitySyncPermissionCheck" engine="simple"
location="component://entityext/minilang/EntitySyncServices.xml" invoke="entitySyncPermissionCheck">
<service name="entitySyncPermissionCheck" engine="groovy"
location="component://entityext/groovyScripts/EntitySyncServices.groovy" invoke="entitySyncPermissionCheck">
<description>Entity sync permission Checking Logic</description>
<implements service="permissionInterface"/>
</service>
Expand Down
4 changes: 2 additions & 2 deletions framework/webtools/webapp/webtools/WEB-INF/controller.xml
Expand Up @@ -503,9 +503,9 @@ under the License.

<!-- EntitySync requests -->
<request-map uri="EntitySyncStatus"><security https="true" auth="true"/><response name="success" type="view" value="EntitySyncStatus"/></request-map>
<request-map uri="resetEntitySyncStatusToNotStarted">
<request-map uri="resetEntitySyncStatus">
<security https="true" auth="true"/>
<event type="service" path="" invoke="resetEntitySyncStatusToNotStarted"/>
<event type="service" path="" invoke="resetEntitySyncStatus"/>
<response name="success" type="view" value="EntitySyncStatus"/>
<response name="error" type="view" value="EntitySyncStatus"/>
</request-map>
Expand Down
2 changes: 1 addition & 1 deletion framework/webtools/widget/EntitySyncForms.xml
Expand Up @@ -36,7 +36,7 @@ under the License.
</field>

<field use-when="&quot;ESR_RUNNING&quot;.equals(runStatusId)" name="resetStatus" title=" " widget-style="smallSubmit">
<hyperlink description="${uiLabelMap.WebtoolsSyncResetRunStatus}" target="resetEntitySyncStatusToNotStarted" also-hidden="false">
<hyperlink description="${uiLabelMap.WebtoolsSyncResetRunStatus}" target="resetEntitySyncStatus" also-hidden="false">
<parameter param-name="entitySyncId"/>
</hyperlink>
</field>
Expand Down

0 comments on commit c654d9b

Please sign in to comment.