Created
June 28, 2017 02:05
-
-
Save orthros/07ce924ae494dd1f99a7d682ee79de16 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<mule xmlns:db="http://www.mulesoft.org/schema/mule/db" xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" | |
xmlns:spring="http://www.springframework.org/schema/beans" | |
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-current.xsd | |
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd | |
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd | |
http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd | |
http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd"> | |
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/> | |
<db:generic-config name="AzConnection" url="jdbc:sqlserver://sq-mulesoft.database.windows.net:1433;database=db-bounty;user={USERNAME};password={PASSWORD};encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30;" driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver" doc:name="Generic Database Configuration"/> | |
<flow name="ghintegrationFlow"> | |
<http:listener config-ref="HTTP_Listener_Configuration" path="/bounty" allowedMethods="post " doc:name="Entrance" metadata:id="62c887e2-247a-4df8-8f71-795dcea14978"/> | |
<dw:transform-message doc:name="Transform Message" metadata:id="4038f98a-b70d-467c-9712-e6ffb947a93d"> | |
<dw:set-payload><![CDATA[%dw 1.0 | |
%output application/java | |
--- | |
{ | |
userId: payload.comment.body, | |
body: payload.comment.body as :string, | |
repositoryID: payload.repository.id as :string, | |
issueId: payload.issue.id as :string, | |
confirmedId: payload.comment.user.login, | |
action : payload.action as :string | |
}]]></dw:set-payload> | |
</dw:transform-message> | |
<db:execute-ddl config-ref="AzConnection" doc:name="Database"> | |
<db:dynamic-query><![CDATA[begin tran | |
if exists (select * from dbo.BountyfulUsers with (updlock,serializable) where dbo.BountyfulUsers.UseName = '#[payload.userId]') | |
begin | |
update dbo.BountyfulUsers set BountiesCompleted += 1 | |
where dbo.BountyfulUsers.UseName = '#[payload.userId]' | |
end | |
else | |
begin | |
insert into dbo.BountyfulUsers (UseName, BountiesCompleted) | |
values ('#[payload.userId]', 1) | |
end | |
commit tran]]></db:dynamic-query> | |
</db:execute-ddl> | |
<set-payload value="#[true]" doc:name="Set Payload"/> | |
</flow> | |
</mule> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment