Skip to content

Commit

Permalink
Merge pull request #29 from hotwax/oms-rest
Browse files Browse the repository at this point in the history
Used oms-rest and removed the old pattern to call the oms api
  • Loading branch information
dixitdeepak authored Sep 3, 2024
2 parents f0f510d + 4301375 commit 18365b1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 45 deletions.
57 changes: 13 additions & 44 deletions service/co/hotwax/common/CommonServices.xml
Original file line number Diff line number Diff line change
@@ -1,59 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<services xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://moqui.org/xsd/service-definition-3.xsd">
<service verb="run" noun="OmsApi" type="interface">
<service verb="autoComplete" noun="SolrFacet" type="oms-rest" location="AutoCompleteSolrFacet" method="post">
<in-parameters>
<parameter name="token"/>
<parameter name="omsBaseUrl"/>
</in-parameters>
</service>
<service verb="autoComplete" noun="OmsSolrFacetApi" type="interface">
<in-parameters>
<parameter name="facetToSelect" type="String"/>
<parameter name="coreName" type="String"/>
<parameter name="docType" type="String"/>
<parameter name="searchfield" type="String"/>
<parameter name="jsonQuery" type="String"/>
<parameter name="noConditionFind" type="String"/>
<parameter name="limit" type="String"/>
<parameter name="q" type="String"/>
<parameter name="term" type="String"/>
<parameter name="offset" type="String"/>
<parameter name="facetToSelect"/>
<parameter name="coreName"/>
<parameter name="docType"/>
<parameter name="searchfield"/>
<parameter name="jsonQuery"/>
<parameter name="noConditionFind"/>
<parameter name="limit"/>
<parameter name="q"/>
<parameter name="term"/>
<parameter name="offset"/>
</in-parameters>
<out-parameters>
<parameter name="facetResponse"/>
<parameter name="response"/>
</out-parameters>
</service>
<service verb="autoComplete" noun="OmsSolrFacet" type="remote-rest" location="${omsBaseUrl}/api/AutoCompleteSolrFacet?token=${token}" method="post" transaction-timeout="3600">
<implements service="co.hotwax.common.CommonServices.run#OmsApi"/>
<implements service="co.hotwax.common.CommonServices.autoComplete#OmsSolrFacetApi"/>
</service>
<service verb="run" noun="SolrQuery" type="oms-rest" location="solr-query" method="post">
<service verb="solr" noun="Query" type="oms-rest" location="solr-query" method="post">
<in-parameters>
<parameter name="json" type="Map"/>
</in-parameters>
<out-parameters>
<parameter name="response" type="Map"/>
</out-parameters>
</service>
<service verb="autoComplete" noun="SolrFacet" transaction-timeout="3600">
<implements service="co.hotwax.common.CommonServices.autoComplete#OmsSolrFacetApi"/>
<actions>
<!-- In case of schedule job run no user logged in, use system user to get the token-->
<set field="userName" from="ec.user.username" default-value="${System.getProperty('default.oms.user')}"/>
<script>
omsBaseUrl = co.hotwax.util.MaargUtil.getOmsInstanceUrl(ec.ecfi);
token = co.hotwax.util.MaargUtil.getOmsJwtToken(ec.ecfi, userName);
</script>
<if condition="!token">
<return error="true" message="Unable to generate oms token, check JWT configuration"/>
</if>
<if condition="!omsBaseUrl">
<return error="true" message="OMS base url not found"/>
</if>
<service-call name="co.hotwax.common.CommonServices.autoComplete#OmsSolrFacet" transaction-timeout="3600"
in-map="context + [omsBaseUrl: omsBaseUrl, token: token]" transaction="force-new"
out-map="facetResponse"/>
</actions>
</service>

</services>
2 changes: 1 addition & 1 deletion service/co/hotwax/product/ProductFacilityServices.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
<if condition="fieldsToSelect">
<set field="queryObject.fields" from="fieldsToSelect"/>
</if>
<service-call name="co.hotwax.common.CommonServices.run#SolrQuery" in-map="[json:queryObject]" out-map="outResult"/>
<service-call name="co.hotwax.common.CommonServices.solr#Query" in-map="[json:queryObject]" out-map="outResult"/>
<if condition="outResult">
<set field="productDetail.products" from="outResult.response.docs"/>
<set field="productDetail.totalCount" from="outResult.response.numFound"/>
Expand Down

0 comments on commit 18365b1

Please sign in to comment.