Skip to content

Instantly share code, notes, and snippets.

View jonathanvila's full-sized avatar

Jonathan Vila jonathanvila

View GitHub Profile
@jonathanvila
jonathanvila / features.xml
Created November 1, 2014 13:32
karaf features
<?xml version="1.0" encoding="UTF-8"?>
<features name="Tesipro" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0">
<repository>mvn:org.apache.camel.karaf/apache-camel/2.12.2/xml/features</repository>
<repository>mvn:org.apache.activemq/activemq-karaf/5.9.0/xml/features</repository>
<repository>mvn:org.apache.cxf.karaf/apache-cxf/2.7.7/xml/features</repository>
<feature name="tesipro-requisites" resolver="(obr)" start-level="60">
<!-- Container dependencies -->
@Reference(referenceInterface = AspectRatioCalculator.class, cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE, policy = ReferencePolicy.DYNAMIC)
private final Map<String, AspectRatioCalculator> aspectRatioCalculators = new ConcurrentHashMap<String, AspectRatioCalculator>();
protected void bindAspectRatioCalculators(final AspectRatioCalculator arc) {
LOG.debug("Registering [{}] as aspect ratio calculator for resource type [{}]", arc.getClass().getName(), arc.getResourceType());
this.aspectRatioCalculators.put(arc.getResourceType(), arc);
}
protected void unbindAspectRatioCalculators(final AspectRatioCalculator arc) {
LOG.debug("Unregistering [{}] as aspect ratio calculator for resource type [{}]", arc.getClass().getName(), arc.getResourceType());
@Test
public void productSplitter() {
CamelContext context = new DefaultCamelContext();
try {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() {
from("file:src/test/resources/messages/products.xml").
split(xpath("//Skus/Sku")).
setHeader("SkuID", xpath("//Sku/Id")).convertBodyTo(String.class).to("direct:end");
from("file://src/test/resources/messages?fileName=products.xml").
log("Source Body : ${body}").
to("stream:out").
split(xpath("//Skus/Sku")).log("Split Body : ${body}").
setHeader("SkuID", xpath("//Sku/Id")).
convertBodyTo(String.class).to("mock:end");
public void configure() {
from("direct:products").
from("direct:prices").
split(xpath("//Skus/Sku|//skus/sku")).
setHeader("SkuID", xpath("//Sku/@Id|//sku/@id", String.class)).convertBodyTo(String.class).
aggregate(header("SkuID"), new GroupedMessageAggregationStrategy()).completionSize(2).completionTimeout(2000).
to("mock:end");
}
public void configure() {
from("direct:products", "direct:prices").to("direct:combined");
from("direct:combined").
split(xpath("//Skus/Sku|//skus/sku")).
setHeader("SkuID", xpath("//Sku/@Id|//sku/@id", String.class)).convertBodyTo(String.class).
aggregate(header("SkuID"), new GroupedMessageAggregationStrategy()).completionSize(4).
log("Aggregated : ${body}").
to("mock:end");
}
@jonathanvila
jonathanvila / MapToXMLTransformer.java
Last active February 1, 2017 18:00
Transforming List<Map<String,String>> into a XML grouping by a value of the map
public class MapToXMLTransformer {
/*
SKU_ID, DATE_EFF, DATE_INAC, VAT_CODE_ATT, PCNT_TO_APLY
Origin = List<HashMap<String,String>>
[ [skuid=10, date_eff=JAN, date_inac=FEB, vat_code_att=S, pcnt_to_aply=80],
[skuid=10, date_eff=JAN, date_inac=FEB, vat_code_att=Z, pcnt_to_aply=20],
[skuid=10, date_eff=MAR, date_inac=APR, vat_code_att=S, pcnt_to_aply=100]
]
@jonathanvila
jonathanvila / gist:09f461527e805bbc642e21bd1ca37b84
Created February 1, 2017 18:08
Transform a List<Map<String,String>> to a String ( xml formatted ) using grouping
Origin = List<HashMap<String,String>>
[ [skuid=10, date_eff=JAN, date_inac=FEB, vat_code_att=S, pcnt_to_aply=80],
[skuid=10, date_eff=JAN, date_inac=FEB, vat_code_att=Z, pcnt_to_aply=20],
[skuid=10, date_eff=MAR, date_inac=APR, vat_code_att=S, pcnt_to_aply=100]
]
Destination = String
<SkuTax skuId="10">
@jonathanvila
jonathanvila / sonar-preview-output.txt
Created July 12, 2017 07:21
Output for maven sonar:sonar with preview as analysis.mode
[INFO] ------------- Scan rip
[INFO] Load server rules
[INFO] Load server rules (done) | time=865ms
[INFO] Base dir: /Users/jonathan.vila/workspace/rms-to-osp
[INFO] Working dir: /Users/jonathan.vila/workspace/rms-to-osp/target/sonar
[INFO] Source paths: pom.xml, src/main/java
[INFO] Test paths: src/test/java
[INFO] Binary dirs: target/classes
[INFO] Source encoding: UTF-8, default locale: en_US
[INFO] Index files
[jonathan@localhost bin]$ ./rhamt-cli --input ../samples/jee-example-app-1.0.0.ear --output ../output --source weblogic --target eap:7
Using RHAMT at /home/jonathan/workspace/windup-distribution/target/rhamt-cli-4.2.0-SNAPSHOT-offline/rhamt-cli-4.2.0-SNAPSHOT
Warning: JAVA_HOME environment variable is not set.
> Red Hat Application Migration Toolkit (RHAMT) CLI, version 4.2.0-SNAPSHOT.
Red Hat Application Migration Toolkit (RHAMT) CLI, version [ ] - by Red Hat, Inc. [ https://developers.redhat.com/products/rhamt/overview/ ]
WARNING: No packages were set in --packages. This will cause all .jar files to be decompiled and can possibly take a long time. Check the RHAMT User Guide for performance tips.