refactoring and adding camel business proxy

This commit is contained in:
Nicolas Héron 2018-12-29 23:05:41 +01:00
commit a474dcf891
876 changed files with 1692 additions and 1038 deletions

View file

@ -0,0 +1,52 @@
/*
* Copyright 2014 Pymma Software
*
* Licensed 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.
*/
package org.chtijbug.drools.common.date;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* Created by IntelliJ IDEA.
* Date: 04/06/13
* Time: 16:38
* To change this template use File | Settings | File Templates.
*/
public class DateHelper {
public static String sFormat = "yyyy-MM-dd";
public static Date getDate(String sDate) throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat(sFormat);
return sdf.parse(sDate);
}
public static Date getDate(String sDate, String anotherFormat)
throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat(anotherFormat);
return sdf.parse(sDate);
}
public static String getDate(Date date) {
SimpleDateFormat sdf = new SimpleDateFormat(sFormat);
String formatedDate = sdf.format(date);
return formatedDate;
}
public static String getDate(Date date, String anotherFormat) {
SimpleDateFormat sdf = new SimpleDateFormat(anotherFormat);
String formatedDate = sdf.format(date);
return formatedDate;
}
}

View file

@ -0,0 +1,36 @@
/*
* Copyright 2014 Pymma Software
*
* Licensed 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.
*/
package org.chtijbug.drools.common.jaxb;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import java.io.StringWriter;
public final class JAXBContextUtils {
public static <T> String marshallObjectAsString(Class<T> clazz, T object) throws JAXBException {
JAXBContext jaxbContext = JAXBContext.newInstance(clazz);
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
// output pretty printed
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
StringWriter writer = new StringWriter();
jaxbMarshaller.marshal(object, writer);
return writer.toString();
}
}

View file

@ -0,0 +1,46 @@
/*
* Copyright 2014 Pymma Software
*
* Licensed 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.
*/
package org.chtijbug.drools.common.reflection;
import java.lang.reflect.Method;
/**
* Created with IntelliJ IDEA.
* User: samuel
* Date: 26/09/12
* Time: 15:45
*/
public class ReflectionUtils {
/**
* Returns <code>true</code> if the method is a getter meaning :
* <ul>
* <li>method name start with 'get' </li>
* <li>no parameters expected from the method</li>
* <li>the return type of the method is not void</li>
* </ul>
* Otherwise, it will return <code>false</code>
*
* @param method Method
* @return true if the method is a getter. false otherwise.
*/
public static boolean IsGetter(Method method) {
if (!method.getName().startsWith("get")) return false;
if (method.getParameterTypes().length != 0) return false;
if (void.class.equals(method.getReturnType())) return false;
return true;
}
}

View file

@ -0,0 +1,26 @@
package org.chtijbug.drools.common.rest;
public class InputElement {
private String jsonInput;
private String className;
public String getJsonInput() {
return jsonInput;
}
public void setJsonInput(String jsonInput) {
this.jsonInput = jsonInput;
}
public String getClassName() {
return className;
}
public void setClassName(String className) {
this.className = className;
}
}

View file

@ -0,0 +1,16 @@
package org.chtijbug.drools.common.rest;
import java.util.List;
public class MultipleInputs {
private List<InputElement> inputElementList;
public List<InputElement> getInputElementList() {
return inputElementList;
}
public void setInputElementList(List<InputElement> inputElementList) {
this.inputElementList = inputElementList;
}
}

View file

@ -0,0 +1,41 @@
/*
* Copyright 2014 Pymma Software
*
* Licensed 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.
*/
package org.chtijbug.drools.common.jaxb;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class JAXBContextUtilsTest {
@Test
public void testMarshallObjectAsString() throws Exception {
ToTestClass toTestClass = new ToTestClass();
toTestClass.setAttr1("attr1");
toTestClass.setAttr2("attr2");
String toEvaluate = JAXBContextUtils.marshallObjectAsString(ToTestClass.class, toTestClass);
assertThat(toEvaluate).isNotNull();
assertThat(toEvaluate).isEqualTo("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" +
"<toTestClass>\n" +
" <attr1>attr1</attr1>\n" +
" <attr2>attr2</attr2>\n" +
"</toTestClass>\n");
}
}

View file

@ -0,0 +1,49 @@
/*
* Copyright 2014 Pymma Software
*
* Licensed 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.
*/
package org.chtijbug.drools.common.jaxb;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
@XmlType(propOrder = {"attr1", "attr2"})
public class ToTestClass {
private String attr1;
private String attr2;
public ToTestClass() {
}
public String getAttr1() {
return attr1;
}
public void setAttr1(String attr1) {
this.attr1 = attr1;
}
public String getAttr2() {
return attr2;
}
public void setAttr2(String attr2) {
this.attr2 = attr2;
}
}

View file

@ -0,0 +1,64 @@
/*
* Copyright 2014 Pymma Software
*
* Licensed 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.
*/
package org.chtijbug.drools.common.reflection;
import org.junit.Test;
import java.lang.reflect.Method;
import static org.junit.Assert.*;
/**
* Created with IntelliJ IDEA.
* User: samuel
* Date: 01/10/12
* Time: 09:42
*/
public class ReflectionUtilsTestCase {
@Test
public void runIsGetter() {
try {
Method methodToEval = TestClass.class.getMethod("getProperty");
assertTrue(ReflectionUtils.IsGetter(methodToEval));
methodToEval = TestClass.class.getMethod("execute");
assertFalse(ReflectionUtils.IsGetter(methodToEval));
} catch (NoSuchMethodException e) {
e.printStackTrace();
fail();
}
}
private class TestClass {
private String property;
public String getProperty() {
return property;
}
public void execute() {
}
}
}