Initial COMMIT
This commit is contained in:
commit
2fd8b2f53d
254 changed files with 26776 additions and 0 deletions
19
drools-framework-common/drools-framework-common.iml
Normal file
19
drools-framework-common/drools-framework-common.iml
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Maven: junit:junit:4.12" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.guava:guava:13.0.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-io:commons-io:2.1" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.assertj:assertj-core:3.10.0" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
50
drools-framework-common/pom.xml
Normal file
50
drools-framework-common/pom.xml
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<?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/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<parent>
|
||||
<artifactId>pymma-jbpm-platform-parent</artifactId>
|
||||
<groupId>com.pymmasoftware.jbpm</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>drools-framework-common</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.10.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
editor.link_modal.header
Reference in a new issue