Skip to content

Instantly share code, notes, and snippets.

View emoran's full-sized avatar
:octocat:
Developing

Edgar Moran emoran

:octocat:
Developing
View GitHub Profile
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.emoran</groupId>
<artifactId>yucelmoran-azure-pipeline</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>mule-application</packaging>
<name>yucelmoran-azure-pipeline</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>yucelmoran-azure-pipeline</id>
<username>yucelmorans</username>
<!-- Treat this auth token like a password. Do not share it with anyone, including Microsoft support. -->
<!-- The generated token expires on or before 17/11/2019 -->
<password>${azure.password}</password>
</server>
%dw 2.0
import try, fail from dw::Runtime
output application/java
fun isDate(value: Any): Boolean = try(() -> value as Date).success
fun getDate(value: Any): Date | Null | Any = ( if ( isDate(value) ) value
as Date as String else value )
---
(payload.fields filter ($."type" != "LOCATION") map {
fieldName : $.name
}).fieldName joinBy ","
%dw 2.0
input payload application/java
output application/java
fun validateField(field) = if ( (field == "REFERENCE")
or (field == "ID") or
(field == "PICKLIST") or
(field == "TEXTAREA") or
(field == "ADDRESS")or
(field == "EMAIL")or
(field == "PHONE") or
payload.sobjects filter ( $.queryable == true and
$.replicateable == true and
$.retrieveable == true and
$.searchable == true and
$.triggerable == true and
($.name == "Account" or
$.name == "Contact" or
$.name =="Project__c")) map $
@emoran
emoran / dynamicFieldsDateValidation
Created February 10, 2022 14:33
Dataweave 2.0 Script that allows to set dynamically fields from a payload and set the date format for strings that are date / datetime
%dw 2.0
import try, fail from dw::Runtime
output application/java
fun isDate(value: Any): Boolean = try(() -> value as Date).success
fun getDate(value: Any): Date | Null | Any = ( if ( isDate(value) ) value
as Date as String else value )
---
@emoran
emoran / scatterGatherDW2.txt
Last active October 21, 2022 19:19
combine scatter gather result Mule 4
%dw 2.0
output application/json
---
flatten (dw::core::Objects::entrySet (payload) map ($[1].payload))
@emoran
emoran / dataweaveEmailValidation
Created July 20, 2021 19:34
validate email in dataweave 1.0
%dw 1.0
%input payload application/json
%output application/json
%var pRegex = /^[^.][a-zA-Z0-9.!#$%&’*+\/=?^_`{|}~-]+@[a-zA-Z0-9-](?!.*?\.\.)[^_ ; ,<>\/\\]+(?:\.[a-zA-Z0-9-]+)[^.]*$/
---
payload filter ($.email != "" and $.email != null and ($.email matches pRegex))
@emoran
emoran / movefiles
Created March 9, 2021 16:53
Move multiple files on linux
for file in "/tmp"/file*; do
sudo mv -- "$file" "/tmp/todelete";
done