submit for CRD

This commit is contained in:
YuCheng Hu 2021-11-18 12:00:03 -05:00
parent 3f11082db2
commit a2f7fdb0d5
51 changed files with 2706 additions and 1 deletions

235
.gitignore vendored Normal file
View File

@ -0,0 +1,235 @@
### Gradle ###
.gradle
build/
# Ignore Gradle GUI config
gradle-app.setting
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar
# Cache of project
.gradletasknamecache
# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
# gradle/wrapper/gradle-wrapper.properties
### Gradle Patch ###
**/build/
### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr
# Sonarlint plugin
.idea/sonarlint
### Intellij+iml ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
### Intellij+iml Patch ###
# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
*.iml
modules.xml
.idea/misc.xml
*.ipr
### Maven ###
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar
.flattened-pom.xml
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr
# Sonarlint plugin
.idea/sonarlint

8
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/

17
.idea/compiler.xml Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="common" />
</profile>
</annotationProcessing>
<bytecodeTargetLevel>
<module name="common" target="11" />
<module name="parent-modules" target="11" />
</bytecodeTargetLevel>
</component>
</project>

12
.idea/dataSources.xml Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="H2 - default" uuid="26933deb-d62f-40b2-b3a6-b308249430a8">
<driver-ref>h2.unified</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>org.h2.Driver</jdbc-driver>
<jdbc-url>jdbc:h2:mem:default</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>
</project>

9
.idea/encodings.xml Normal file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/common/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/common/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component>
</project>

20
.idea/jarRepositories.xml Normal file
View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
</component>
</project>

6
.idea/jpa-buddy.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JpaBuddyIdeaProjectConfig">
<option name="defaultUnitInitialized" value="true" />
</component>
</project>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
</set>
</option>
</component>
</project>

6
.idea/sqldialects.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="SqlDialectMappings">
<file url="file://$PROJECT_DIR$/common/src/test/resources/schema/h2.sql" dialect="H2" />
</component>
</project>

6
.idea/thriftCompiler.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ThriftCompiler">
<compilers />
</component>
</project>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2021 FacilityConneX
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1 +1,19 @@
# Demo-Cars-Rental
# Demo-Cars-Rental
This is demo for CRD request.
## Setting
DB: H2
ORM: Hibernate
## Run
run test function local at: ReservationTest.testMakeReservation
Package: com.crd.toolkits.tests.dao
## Assert
You should get confirmation Number is not null the value is UUID
example:
```shell
11:54:15.901 [main] DEBUG c.c.t.tests.dao.ReservationTest - confirmation Number - [b73faf16-cdb3-4dde-91f2-c904c09cda33]
```

42
common/pom.xml Normal file
View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.crd</groupId>
<artifactId>common</artifactId>
<name>common</name>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>com.crd</groupId>
<artifactId>parent-modules</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<!-- plugins -->
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
</properties>
</project>

View File

@ -0,0 +1,10 @@
package com.crd.demo.common;
/**
* Constants for CRD
*
* @author YuCheng Hu
*/
public class Constants {
public static final String PATH_DATA_EXCHANGE = "/home/crd/sco/dataExchange/";
}

View File

@ -0,0 +1,116 @@
package com.crd.demo.common;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.hibernate.search.annotations.DateBridge;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Resolution;
import javax.persistence.*;
import java.util.Date;
import java.util.Objects;
/**
* DataObject
*
* @author YuCheng Hu
*/
@MappedSuperclass
public abstract class DataObject {
public abstract interface Save {
}
public abstract interface Update {
}
public static final String ID_PROPERTY_NAME = "id";
public static final String CREATE_DATE_PROPERTY_NAME = "createDate";
public static final String MODIFY_DATE_PROPERTY_NAME = "modifyDate";
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id = 0;
private String uuid;
private Date dateC;
private Date dateM;
@JsonProperty
@DocumentId
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
/**
* @return
*/
@JsonProperty
@DateBridge(resolution = Resolution.SECOND)
@Column(nullable = false, updatable = false)
public Date getCreateDate() {
return this.dateC;
}
/**
* @param createDate
*/
public void setCreateDate(Date createDate) {
this.dateC = createDate;
}
/**
* @return
*/
@JsonProperty
@DateBridge(resolution = Resolution.SECOND)
@Column(nullable = false)
public Date getDateC() {
return dateC;
}
public void setDateC(Date dateC) {
this.dateC = dateC;
}
/**
* @return
*/
@JsonProperty
@DateBridge(resolution = Resolution.SECOND)
@Column(nullable = false)
public Date getDateM() {
return dateM;
}
public void setDateM(Date dateM) {
this.dateM = dateM;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
DataObject that = (DataObject) o;
return id == that.id;
}
@Override
public int hashCode() {
return Objects.hash(id);
}
}

View File

@ -0,0 +1,28 @@
package com.crd.demo.common.dao;
import org.hibernate.event.internal.DefaultDeleteEventListener;
import org.hibernate.event.spi.EventSource;
import org.hibernate.persister.entity.EntityPersister;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashSet;
import java.util.Set;
/**
* Delete Event Listener
*
* @author YuCheng Hu
*/
public class DeleteEventListener extends DefaultDeleteEventListener {
private static Logger logger = LoggerFactory.getLogger(DeleteEventListener.class);
/**
* Transient Entity
*/
protected void deleteTransientEntity(EventSource session, Object entity, boolean cascadeDeleteEnabled, EntityPersister persister,
Set transientEntities) {
super.deleteTransientEntity(session, entity, cascadeDeleteEnabled, persister,
transientEntities == null ? new HashSet() : transientEntities);
}
}

View File

@ -0,0 +1,302 @@
package com.crd.demo.common.dao;
import com.crd.demo.common.DataObject;
import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.boot.Metadata;
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import org.hibernate.search.FullTextSession;
import org.hibernate.search.Search;
import org.hibernate.service.ServiceRegistry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
/**
* Factor for DAO
*
* @author YuCheng Hu
*/
public class Factory {
private static Logger logger = LoggerFactory.getLogger(Factory.class);
private static SessionFactory sessionFactory;
private static ServiceRegistry serviceRegistry;
private static int indexBatchSize = 100;
// blocks the commit function from being called - this is useful for unit testing.
private static boolean noCommit = false;
// executes a rollback instead of a commit when commit is called - this is useful for unit testing.
private static boolean autoRollback = false;
// prevents the connection from being closed. This is useful for unit testing.
private static boolean noClose = false;
/**
* Get Hibernate connection Session
*
* @return
*/
public static Session getSession() {
return Factory.getFactory().getCurrentSession();
}
/**
* Get session connection Get
*
* @return
*/
public static SessionFactory getFactory() {
if (Factory.sessionFactory == null)
Factory.sessionFactory = Factory.initSession();
return Factory.sessionFactory;
}
/**
* Get SessionFactory
*
* @return
*/
public static SessionFactory initSession() {
Configuration configuration = new Configuration();
configuration.configure();
serviceRegistry = new StandardServiceRegistryBuilder().configure().build();
Metadata metadata = new MetadataSources(serviceRegistry).getMetadataBuilder().build();
sessionFactory = metadata.getSessionFactoryBuilder().build();
return sessionFactory;
}
/**
* Begin DataBase Transaction
*/
public static void beginTransaction() {
if (!(Factory.getSession().getTransaction() != null && Factory.getSession().getTransaction().isActive())) {
Factory.getSession().getTransaction().begin();
} else {
}
}
public static void commitTransaction() {
if (isAutoRollback()) {
Factory.rollbackTransaction();
return;
}
if (Factory.getSession().getTransaction() != null && Factory.getSession().getTransaction().isActive()) {
if (!noCommit)
Factory.getSession().getTransaction().commit();
}
}
public static void rollbackTransaction() {
if (Factory.getSession().getTransaction() != null && Factory.getSession().getTransaction().isActive())
Factory.getSession().getTransaction().rollback();
}
/**
* Gets an object of type T from Hibernate.
*
* @param <T>
* @param classEntity
* @param id
* @return
*/
@SuppressWarnings("unchecked")
public static <T> T get(Class<T> classEntity, int id) {
Object object = Factory.getSession().get(classEntity, id);
if (object == null)
return null;
return (T) object;
}
/**
* Saves the specified object to the database.
*
* @param object
*/
public static void save(DataObject object) {
if (object == null)
throw new NullPointerException("Object supplied is null");
if (object.getId() > 0)
Factory.getSession().saveOrUpdate(object);
else
Factory.getSession().save(object);
}
/**
* Deletes the specified object.
*
* @param object
*/
public static void delete(DataObject object) {
Factory.getSession().delete(object);
}
/**
* Creates an hibernate criteria object which is used to query against objects.
*
* @param classArg
* @return
*/
public static <T> Criteria createCriteria(Class<T> classArg) {
return Factory.getSession().createCriteria(classArg);
}
/**
* Creates an hibernate criteria object with the specified alias.
*
* @param classArg
* @param alias
* @param <T>
* @return
*/
public static <T> Criteria createCriteria(Class<T> classArg, String alias) {
return Factory.getSession().createCriteria(classArg, alias);
}
/**
* Serializes an object into a byte array.
*
* @param object
* @return
*/
public static byte[] serialize(Object object) throws IOException {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
try {
ObjectOutputStream serializer = new ObjectOutputStream(stream);
serializer.writeObject(object);
serializer.close();
} catch (IOException ex) {
Factory.handleException(ex);
}
byte[] result = stream.toByteArray();
stream.close();
return result;
}
private static void handleException(IOException ex) {
// TODO Auto-generated method stub
}
/**
* Merges the specified instance.
*
* @param obj
*/
public static void merge(DataObject obj) {
Factory.getSession().merge(obj);
}
/**
* Refreshes the specified instance.
*
* @param obj
*/
public static void refresh(DataObject obj) {
Factory.getSession().refresh(obj);
}
/**
* Saves or updates the object.
*
* @param obj
*/
public static void saveOrUpdate(DataObject obj) {
Factory.getSession().saveOrUpdate(obj);
}
/**
* Evicts the specified object from the session.
*
* @param obj
*/
public static void evict(DataObject obj) {
Factory.getSession().evict(obj);
}
/**
* Creates a hibernate query.
*
* @param query
* @return
*/
public static Query createQuery(String query) {
return Factory.getSession().createQuery(query);
}
public static FullTextSession getFullTextSession() {
return Search.getFullTextSession(Factory.getSession());
}
/**
* Closes the session factory. Should only be called when an application is closing.
*/
public static void close() {
if (!isNoClose())
Factory.getFactory().close();
}
/**
* @param noCommit the noCommit to set
*/
public static void setNoCommit(boolean noCommit) {
Factory.noCommit = noCommit;
}
/**
* @return the noCommit
*/
public static boolean isNoCommit() {
return noCommit;
}
/**
* @param autoRollback the autoRollback to set
*/
public static void setAutoRollback(boolean autoRollback) {
Factory.autoRollback = autoRollback;
}
/**
* @return the autoRollback
*/
public static boolean isAutoRollback() {
return autoRollback;
}
/**
* @param noClose the noClose to set
*/
public static void setNoClose(boolean noClose) {
Factory.noClose = noClose;
}
/**
* @return the noClose
*/
public static boolean isNoClose() {
return noClose;
}
}

View File

@ -0,0 +1,95 @@
package com.crd.demo.common.dao.factories;
import com.crd.demo.common.dao.Factory;
import com.crd.demo.common.models.CarType;
import com.crd.demo.common.models.orm.CarInventory;
import com.crd.demo.common.models.orm.CarReservation;
import com.crd.demo.common.models.request.ReservationRequest;
import org.apache.commons.lang3.ObjectUtils;
import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
import java.util.UUID;
/**
* CarFactory to process database query
* @author YuCheng Hu
*/
public class CarFactory {
private final static Logger logger = LoggerFactory.getLogger(CarFactory.class);
/**
* Search ReportManufacturer by ID
*
* @param id
* @return
*/
public static CarInventory getCarInventoryById(Long id) {
logger.debug("Search Database to find ReportManufacturer by ID");
Object obj = Factory.getSession().get(CarInventory.class, id);
if (ObjectUtils.allNotNull(obj))
return (CarInventory) obj;
else
return null;
}
/**
* Search CarInventory by CarType
*
* @param carType
* @return
*/
public static List<CarInventory> getCarInventory(CarType carType) {
logger.debug("Search Database to find ReportManufacturer by ID");
Criteria cr = Factory.createCriteria(CarInventory.class);
cr.add(Restrictions.eq("carType", carType));
cr.add(Restrictions.isNull("confirmationNumber"));
List results = cr.list();
return results;
}
/**
* Search CarInventory by CarType
*
* @param carType
* @return
*/
public static CarReservation createReservation(ReservationRequest reservationRequest, CarInventory carInventory) {
logger.debug("Search Database to find ReportManufacturer by ID");
DateTime dateStart = new DateTime(reservationRequest.getDateReservationStart());
CarReservation carReservation = new CarReservation();
carReservation.setCarInventoryId(carInventory.getId());
carReservation.setDateReservationsStart(dateStart.toDate());
carReservation.setDateReservationsStart(dateStart.plusDays(reservationRequest.getDurationReservation()).toDate());
carReservation.setConfirmationNumber(UUID.randomUUID().toString());
Factory.save(carReservation);
return carReservation;
}
/**
*
* @param carInventory
* @return
*/
public static CarInventory saveCarInventory(CarInventory carInventory) {
logger.debug("Save CarInventory");
Factory.save(carInventory);
return carInventory;
}
}

View File

@ -0,0 +1,11 @@
package com.crd.demo.common.models;
/**
*
*/
public enum CarType {
SEDAN,
SUV,
VAN
}

View File

@ -0,0 +1,68 @@
package com.crd.demo.common.models.orm;
import com.crd.demo.common.DataObject;
import com.crd.demo.common.models.CarType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
/**
*
*/
@Entity
@Table(catalog = "CRD", name = "Car_Inventory")
public class CarInventory extends DataObject implements Serializable {
private static final long serialVersionUID = 5530454436970805656L;
private static Logger logger = LoggerFactory.getLogger(CarInventory.class);
@Column(name = "CAR_NAME")
private String carName;
@Column(name = "CAR_TYPE")
@Enumerated(EnumType.ORDINAL)
private CarType carType;
@Column(name = "CONFIRMATION_NUMBER")
private String confirmationNumber;
/**
* Constructor
*/
public CarInventory() {
}
public static long getSerialVersionUID() {
return serialVersionUID;
}
public String getCarName() {
return carName;
}
public void setCarName(String carName) {
this.carName = carName;
}
public CarType getCarType() {
return carType;
}
public void setCarType(CarType carType) {
this.carType = carType;
}
public String getConfirmationNumber() {
return confirmationNumber;
}
public void setConfirmationNumber(String confirmationNumber) {
this.confirmationNumber = confirmationNumber;
}
}

View File

@ -0,0 +1,93 @@
package com.crd.demo.common.models.orm;
import com.crd.demo.common.DataObject;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
import java.util.UUID;
/**
* ORM For Table: CARS
*/
@Entity
@Table(catalog = "CRD", name = "Car_Reservation")
public class CarReservation extends DataObject implements Serializable {
@Column(name = "CAR_INVENTORY_ID")
private Long carInventoryId;
@Column(name = "CONFIRMATION_NUMBER")
private String confirmationNumber;
@Column(name = "DATE_RESERVATION_START")
private Date dateReservationsStart;
@Column(name = "DATE_RESERVATION_END")
private Date dateReservationEnd;
@Column(name = "DATE_ACTUAL_START")
private Date dateActualStart;
@Column(name = "DATE_ACTUAL_END")
private Date dateActualEnd;
/**
* Constructor
*/
public CarReservation() {
this.setDateC(new Date());
this.setDateM(new Date());
this.setUuid(UUID.randomUUID().toString());
}
public Long getCarInventoryId() {
return carInventoryId;
}
public void setCarInventoryId(Long carInventoryId) {
this.carInventoryId = carInventoryId;
}
public String getConfirmationNumber() {
return confirmationNumber;
}
public void setConfirmationNumber(String confirmationNumber) {
this.confirmationNumber = confirmationNumber;
}
public Date getDateReservationsStart() {
return dateReservationsStart;
}
public void setDateReservationsStart(Date dateReservationsStart) {
this.dateReservationsStart = dateReservationsStart;
}
public Date getDateReservationEnd() {
return dateReservationEnd;
}
public void setDateReservationEnd(Date dateReservationEnd) {
this.dateReservationEnd = dateReservationEnd;
}
public Date getDateActualStart() {
return dateActualStart;
}
public void setDateActualStart(Date dateActualStart) {
this.dateActualStart = dateActualStart;
}
public Date getDateActualEnd() {
return dateActualEnd;
}
public void setDateActualEnd(Date dateActualEnd) {
this.dateActualEnd = dateActualEnd;
}
}

View File

@ -0,0 +1,50 @@
package com.crd.demo.common.models.request;
import com.crd.demo.common.models.CarType;
import java.io.Serializable;
import java.util.Date;
/**
* SearchRequest Object, UI can send search String and related pagination
*
* @author YuCheng Hu
*/
public class ReservationRequest implements Serializable {
private static final long serialVersionUID = 6474765081240948885L;
private Date dateReservationStart;
private Integer durationReservation;
private CarType carType;
public static long getSerialVersionUID() {
return serialVersionUID;
}
public Date getDateReservationStart() {
return dateReservationStart;
}
public void setDateReservationStart(Date dateReservationStart) {
this.dateReservationStart = dateReservationStart;
}
public Integer getDurationReservation() {
return durationReservation;
}
public void setDurationReservation(Integer durationReservation) {
this.durationReservation = durationReservation;
}
public CarType getCarType() {
return carType;
}
public void setCarType(CarType carType) {
this.carType = carType;
}
}

View File

@ -0,0 +1,130 @@
package com.crd.demo.common.models.response;
import java.io.Serializable;
/**
* MyFileResponse for API my file response
*
* @author YuCheng Hu
*/
public class MyFileResponse implements Serializable {
private static final long serialVersionUID = -5103349220463423614L;
private Long id;
private String azureInputFileUUID;
private String azureInputFileETag;
private String azureOutputFileUUID;
private String azureOutputFileETag;
private String customerName;
private String inputFileName;
private Integer fileCountRow;
private Integer fileCountAliasMatch;
private Integer fileCountDirectMatch;
private Integer fileCountNoMatch;
private String dateCreated;
private String uuid;
public String getAzureInputFileUUID() {
return azureInputFileUUID;
}
public void setAzureInputFileUUID(String azureInputFileUUID) {
this.azureInputFileUUID = azureInputFileUUID;
}
public String getAzureInputFileETag() {
return azureInputFileETag;
}
public void setAzureInputFileETag(String azureInputFileETag) {
this.azureInputFileETag = azureInputFileETag;
}
public String getAzureOutputFileUUID() {
return azureOutputFileUUID;
}
public void setAzureOutputFileUUID(String azureOutputFileUUID) {
this.azureOutputFileUUID = azureOutputFileUUID;
}
public String getAzureOutputFileETag() {
return azureOutputFileETag;
}
public void setAzureOutputFileETag(String azureOutputFileETag) {
this.azureOutputFileETag = azureOutputFileETag;
}
public String getCustomerName() {
return customerName;
}
public void setCustomerName(String customerName) {
this.customerName = customerName;
}
public String getInputFileName() {
return inputFileName;
}
public void setInputFileName(String inputFileName) {
this.inputFileName = inputFileName;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Integer getFileCountRow() {
return fileCountRow;
}
public void setFileCountRow(Integer fileCountRow) {
this.fileCountRow = fileCountRow;
}
public Integer getFileCountAliasMatch() {
return fileCountAliasMatch;
}
public void setFileCountAliasMatch(Integer fileCountAliasMatch) {
this.fileCountAliasMatch = fileCountAliasMatch;
}
public Integer getFileCountDirectMatch() {
return fileCountDirectMatch;
}
public void setFileCountDirectMatch(Integer fileCountDirectMatch) {
this.fileCountDirectMatch = fileCountDirectMatch;
}
public Integer getFileCountNoMatch() {
return fileCountNoMatch;
}
public void setFileCountNoMatch(Integer fileCountNoMatch) {
this.fileCountNoMatch = fileCountNoMatch;
}
public String getDateCreated() {
return dateCreated;
}
public void setDateCreated(String dateCreated) {
this.dateCreated = dateCreated;
}
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
}

View File

@ -0,0 +1,37 @@
package com.crd.demo.common.models.response;
import java.io.Serializable;
import java.util.Date;
/**
* SearchResponse from Remote Source
*
* @author YuCheng Hu
*/
public class SearchResponse implements Serializable {
private static final long serialVersionUID = -2014480627591149391L;
private String uuid;
private Date currentDate;
public static long getSerialVersionUID() {
return serialVersionUID;
}
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public Date getCurrentDate() {
return currentDate;
}
public void setCurrentDate(Date currentDate) {
this.currentDate = currentDate;
}
}

View File

@ -0,0 +1,15 @@
<?xml version="1.0"?>
<ehcache>
<diskStore path="java.io.tmpdir" />
<defaultCache
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
overflowToDisk="true"
maxElementsOnDisk="10000000"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LRU"
/>
</ehcache>

View File

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">org.mariadb.jdbc.Driver</property>
<property name="hibernate.dialect">org.hibernate.dialect.MariaDBDialect</property>
<property name="hibernate.connection.pool.size">20</property>
<property name="hibernate.connection.autocommit">false</property>
<property name="hibernate.jdbc.batch_size">20</property>
<property name="hibernate.current_session_context_class">thread</property>
<!-- HikariCP -->
<property name="hibernate.connection.provider_class">com.zaxxer.hikari.hibernate.HikariConnectionProvider
</property>
<property name="hibernate.hikari.poolName">HikariPool-Azure</property>
<property name="hibernate.hikari.minimumIdle">5</property>
<property name="hibernate.hikari.maximumPoolSize">10</property>
<property name="hibernate.hikari.idleTimeout">30000</property>
<property name="hibernate.hikari.connectionTestQuery">SELECT 1</property>
<!-- EHCache -->
<property name="hibernate.cache.use_second_level_cache">true</property>
<property name="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</property>
<!-- SEARCH -->
<property name="hibernate.search.default.directory_provider">filesystem</property>
<property name="hibernate.search.default.indexBase">/var/lucene/indexes/5</property>
<mapping class="com.crd.demo.common.models.orm.CarInventory"/>
<mapping class="com.crd.demo.common.models.orm.CarReservation"/>
<event type="delete">
<listener class="com.crd.demo.common.dao.DeleteEventListener" />
</event>
</session-factory>
</hibernate-configuration>

View File

@ -0,0 +1,5 @@
hibernate.connection.driver_class = org.h2.Driver
hibernate.dialect = org.hibernate.dialect.H2Dialect
hibernate.connection.url=jdbc:h2:mem:test;MODE=Mysql;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;INIT=RUNSCRIPT FROM 'classpath:schema/h2.sql'
hibernate.connection.username=sa
hibernate.connection.password=

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Configuration status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Logger name="com" level="trace">
<AppenderRef ref="Console" />
</Logger>
<Root level="all">
</Root>
</Loggers>
</Configuration>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Configuration status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Logger name="com" level="trace">
<AppenderRef ref="Console" />
</Logger>
<Root level="all">
</Root>
</Loggers>
</Configuration>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" ?>
<configuration debug="true">
<appender name="STDOUT"
class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned by default the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder -->
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="debug">
<appender-ref ref="STDOUT"/>
</root>
</configuration>

View File

@ -0,0 +1,22 @@
package com.crd.toolkits.tests.dao;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Test Logger and function
*
* @author YuCheng Hu
*/
public class FirstTest {
private static Logger logger = LoggerFactory.getLogger(FirstTest.class);
/**
* Check test function
*/
@Test
public void testString() {
logger.debug("TEST String");
}
}

View File

@ -0,0 +1,175 @@
package com.crd.toolkits.tests.dao;
import com.crd.demo.common.dao.Factory;
import com.crd.demo.common.dao.factories.CarFactory;
import com.crd.demo.common.models.CarType;
import com.crd.demo.common.models.orm.CarInventory;
import com.crd.demo.common.models.orm.CarReservation;
import com.crd.demo.common.models.request.ReservationRequest;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.RandomUtils;
import org.apache.commons.lang3.StringUtils;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.validation.ValidationException;
import java.util.Date;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* ReservationTest Testing
*
* @author YuCheng Hu
*/
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class ReservationTest {
private static Logger logger = LoggerFactory.getLogger(ReservationTest.class);
@BeforeAll
protected void setUp() throws Exception {
Factory.beginTransaction();
}
@AfterAll
protected void tearDown() throws Exception {
// Factory.commitTransaction();
}
/**
* Tests JPA and database connection
*/
@Test
public void testGetQIndex() throws ValidationException {
CarInventory carInventory = CarFactory.getCarInventoryById(1L);
logger.debug("carInventory Name for Id 1 - {}/{}", carInventory.getCarName(), carInventory.getCarType());
// make sure the reportManufacturer was found
assertNotNull(carInventory);
}
/**
* Tests to check the size of Inventory
*/
@Test
public void testSizeOfInventory() throws ValidationException {
ReservationRequest reservationRequest = createReservationRequest();
List<CarInventory> carInventoryList = CarFactory.getCarInventory(reservationRequest.getCarType());
logger.debug("carInventory List - {}/{}", reservationRequest.getCarType(), carInventoryList.size());
}
/**
* Test Save database for Reservation
*
* @throws ValidationException
*/
@Test
public void testAddRecordToReservation() throws ValidationException {
ReservationRequest reservationRequest = createReservationRequest();
List<CarInventory> carInventoryList = CarFactory.getCarInventory(reservationRequest.getCarType());
//
CarReservation carReservation = CarFactory.createReservation(reservationRequest, carInventoryList.get(0));
logger.debug("carReservation CN - {}", carReservation.getConfirmationNumber());
}
/**
* MAIN TEST Function for Reservation logic
*
* @throws ValidationException
*/
@Test
public void testMakeReservation() throws ValidationException {
CarInventory carInventory = null;
String confirmationNumber = null;
// Build Request
ReservationRequest reservationRequest = createReservationRequest();
// Check Inventory
List<CarInventory> carInventoryList = checkInventoryAvailable(reservationRequest);
if (CollectionUtils.isNotEmpty(carInventoryList)) {
logger.debug("carInventory List - {}/{}", reservationRequest.getCarType(), carInventoryList.size());
carInventory = carInventoryList.get(RandomUtils.nextInt(0, carInventoryList.size()));
}
// Make Reservation
if (ObjectUtils.isNotEmpty(carInventory)) {
confirmationNumber = processReservation(reservationRequest, carInventory);
} else {
logger.debug("NO carInventory");
}
// UPDATE Inventory
if (StringUtils.isNotEmpty(confirmationNumber))
updateInventory(carInventory, confirmationNumber);
logger.debug("confirmation Number - [{}]", carInventory.getConfirmationNumber());
assertNotNull(carInventory.getConfirmationNumber());
}
/**
* Build reservationRequest
*
* @return
*/
private ReservationRequest createReservationRequest() {
ReservationRequest reservationRequest = new ReservationRequest();
reservationRequest.setDateReservationStart(new Date());
reservationRequest.setDurationReservation(2);
reservationRequest.setCarType(CarType.SUV);
return reservationRequest;
}
/**
* Check checkInventory Size
*
* @param reservationRequest
* @return
*/
private List<CarInventory> checkInventoryAvailable(ReservationRequest reservationRequest) {
return CarFactory.getCarInventory(reservationRequest.getCarType());
}
/**
* Process Reservation and get confirmationNumber
*
* @param reservationRequest
* @param carInventory
* @return
*/
private String processReservation(ReservationRequest reservationRequest, CarInventory carInventory) {
CarReservation carReservation = CarFactory.createReservation(reservationRequest, carInventory);
logger.debug("carReservation CN - {}", carReservation.getConfirmationNumber());
return carReservation.getConfirmationNumber();
}
/**
* Save CarInventory
*
* @param carInventory
* @param confirmationNumber
* @return
*/
private CarInventory updateInventory(CarInventory carInventory, String confirmationNumber) {
carInventory.setConfirmationNumber(confirmationNumber);
CarFactory.saveCarInventory(carInventory);
logger.debug("carInventory CN - {}", carInventory.getConfirmationNumber());
return carInventory;
}
}

View File

@ -0,0 +1,15 @@
<?xml version="1.0"?>
<ehcache>
<diskStore path="java.io.tmpdir" />
<defaultCache
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
overflowToDisk="true"
maxElementsOnDisk="10000000"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LRU"
/>
</ehcache>

View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.pool.size">100</property>
<property name="hibernate.connection.autocommit">false</property>
<property name="hibernate.jdbc.batch_size">500</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.id.new_generator_mappings">true</property>
<property name="hibernate.order_inserts">true</property>
<property name="hibernate.order_updates">true</property>
<property name="dialect">org.hibernate.dialect.SQLServer2012Dialect</property>
<!-- HikariCP -->
<property name="hibernate.connection.provider_class">com.zaxxer.hikari.hibernate.HikariConnectionProvider
</property>
<property name="hibernate.hikari.poolName">HikariPool-Azure</property>
<property name="hibernate.hikari.minimumIdle">5</property>
<property name="hibernate.hikari.maximumPoolSize">10</property>
<property name="hibernate.hikari.idleTimeout">30000</property>
<property name="hibernate.hikari.connectionTestQuery">SELECT 1</property>
<!-- EHCache -->
<property name="hibernate.cache.use_second_level_cache">true</property>
<property name="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory
</property>
<!-- MAPPING -->
<mapping class="com.crd.demo.common.models.orm.CarInventory"/>
<mapping class="com.crd.demo.common.models.orm.CarReservation"/>
</session-factory>
</hibernate-configuration>

View File

@ -0,0 +1,5 @@
hibernate.connection.driver_class = org.h2.Driver
hibernate.dialect = org.hibernate.dialect.H2Dialect
hibernate.connection.url=jdbc:h2:mem:test;MODE=Mysql;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;INIT=RUNSCRIPT FROM 'classpath:schema/h2.sql'
hibernate.connection.username=sa
hibernate.connection.password=

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Configuration status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Logger name="com" level="trace">
<AppenderRef ref="Console" />
</Logger>
<Root level="all">
</Root>
</Loggers>
</Configuration>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Configuration status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Logger name="com" level="trace">
<AppenderRef ref="Console" />
</Logger>
<Root level="all">
</Root>
</Loggers>
</Configuration>

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" ?>
<configuration debug="true">
<appender name="STDOUT"
class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned by default the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder -->
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>
%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n
</Pattern>
</layout>
</appender>
<root level="debug">
<appender-ref ref="STDOUT"/>
</root>
</configuration>

View File

@ -0,0 +1,59 @@
CREATE SCHEMA IF NOT EXISTS CRD;
create table IF NOT EXISTS CRD.CAR_INVENTORY
(
ID INT auto_increment,
CAR_NAME VARCHAR2,
CAR_TYPE int,
uuid VARCHAR2,
CONFIRMATION_NUMBER VARCHAR2,
dateC DATETIME,
dateM DATETIME
);
create unique index IF NOT EXISTS CRD.CAR_INVENTORY_ID_UINDEX
on CRD.CAR_INVENTORY (ID);
alter table CRD.CAR_INVENTORY
add constraint CAR_INVENTORY_PK
primary key (ID);
INSERT INTO CRD.CAR_INVENTORY (CAR_NAME, CAR_TYPE, dateM, dateC)
VALUES ('Toyota', 0, now(), now());
INSERT INTO CRD.CAR_INVENTORY (CAR_NAME, CAR_TYPE, dateM, dateC)
VALUES ('Toyota', 1, now(), now());
INSERT INTO CRD.CAR_INVENTORY (CAR_NAME, CAR_TYPE, dateM, dateC)
VALUES ('Toyota', 2, now(), now());
INSERT INTO CRD.CAR_INVENTORY (CAR_NAME, CAR_TYPE, dateM, dateC)
VALUES ('GMC', 0, now(), now());
INSERT INTO CRD.CAR_INVENTORY (CAR_NAME, CAR_TYPE, dateM, dateC)
VALUES ('GMC', 1, now(), now());
INSERT INTO CRD.CAR_INVENTORY (CAR_NAME, CAR_TYPE, dateM, dateC)
VALUES ('GMC', 2, now(), now());
INSERT INTO CRD.CAR_INVENTORY (CAR_NAME, CAR_TYPE, dateM, dateC)
VALUES ('SUBARU', 0, now(), now());
INSERT INTO CRD.CAR_INVENTORY (CAR_NAME, CAR_TYPE, dateM, dateC)
VALUES ('SUBARU', 1, now(), now());
INSERT INTO CRD.CAR_INVENTORY (CAR_NAME, CAR_TYPE, dateM, dateC)
VALUES ('SUBARU', 2, now(), now());
INSERT INTO CRD.CAR_INVENTORY (CAR_NAME, CAR_TYPE, dateM, dateC)
VALUES ('SUBARU', 1, now(), now());
INSERT INTO CRD.CAR_INVENTORY (CAR_NAME, CAR_TYPE, CONFIRMATION_NUMBER, dateM, dateC)
VALUES ('Toyota', 1, 'XX', now(), now());
create table IF NOT EXISTS CRD.CAR_RESERVATION
(
ID INT auto_increment,
CAR_INVENTORY_ID INT,
CONFIRMATION_NUMBER VARCHAR2,
uuid VARCHAR2,
DATE_RESERVATION_START DATETIME,
DATE_RESERVATION_END DATETIME,
DATE_ACTUAL_START DATETIME,
DATE_ACTUAL_END DATETIME,
dateC DATETIME,
dateM DATETIME
);

390
pom.xml Normal file
View File

@ -0,0 +1,390 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.crd</groupId>
<artifactId>parent-modules</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Demo-Cars-Rental</name>
<description>Car Rental Coding Assignment</description>
<url>https://github.com/honeymoose</url>
<developers>
<developer>
<name>YuCheng Hu</name>
<id>honeymoose</id>
<email>huyuchengus@gmail.com</email>
<timezone>-5</timezone>
<organization>Open Source</organization>
<roles>
<role>Sr. Java Developer</role>
</roles>
</developer>
</developers>
<licenses>
<license>
<name>MIT License</name>
<url>https://www.opensource.org/licenses/mit-license.php</url>
<distribution>repo</distribution>
</license>
</licenses>
<modules>
<module>common</module>
</modules>
<properties>
<!-- Generic properties -->
<java.version>11</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<!-- Logging -->
<slf4j.version>1.7.30</slf4j.version>
<log4j.version>1.2.17</log4j.version>
<log4j2.version>2.2</log4j2.version>
<!-- APACHE COMMONS-->
<commons-io.version>2.11.0</commons-io.version>
<commons-lang.version>2.6</commons-lang.version>
<commons-lang3.version>3.11</commons-lang3.version>
<commons-cli.version>1.4</commons-cli.version>
<maven-war-plugin.version>3.0.0</maven-war-plugin.version>
<!-- UTILS -->
<guava.version>30.1.1-jre</guava.version>
<!-- Hibernate / JPA -->
<hibernate.version>4.3.5.Final</hibernate.version>
<!-- Bean validation -->
<hibernate-validator.version>4.3.1.Final</hibernate-validator.version>
<!-- Database access -->
<tomcat-jdbc.version>7.0.42</tomcat-jdbc.version>
<ehcache.version>2.6.8</ehcache.version>
<hsqldb.version>2.3.2</hsqldb.version>
<!-- DATA STRUCTURES -->
<jackson.version>2.12.4</jackson.version>
<!-- Test -->
<hamcrest.version>2.2</hamcrest.version>
<hamcrest-all.version>1.3</hamcrest-all.version>
<!-- CDN & CLOUD -->
<jclouds.version>1.9.0</jclouds.version>
<modelmapper.version>2.4.4</modelmapper.version>
<lombok.version>1.18.20</lombok.version>
<moneta.version>1.3</moneta.version>
<jmh-core.version>1.33</jmh-core.version>
<exec-maven-plugin.version>3.0.0</exec-maven-plugin.version>
<maven-surefire-plugin.version>2.21.0</maven-surefire-plugin.version>
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
</properties>
<dependencies>
<!-- COMMON -->
<!-- LOG -->
<!-- <dependency>-->
<!-- <groupId>org.apache.logging.log4j</groupId>-->
<!-- <artifactId>log4j-slf4j18-impl</artifactId>-->
<!-- <version>2.14.0</version>-->
<!-- </dependency>-->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.5</version>
</dependency>
<!-- APACHE COMMONS -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.20</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>3.6.1</version>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
<version>2.7.6</version>
</dependency>
<!-- utils -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.10.13</version>
</dependency>
<dependency>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>2.1.3</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity-tools</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
<version>1.1.6</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
</dependency>
<dependency>
<groupId>com.google.gdata</groupId>
<artifactId>core</artifactId>
<version>1.47.1</version>
</dependency>
<dependency>
<groupId>org.ow2.orchestra.eclipse.birt</groupId>
<artifactId>org.ow2.orchestra.eclipse.birt.core</artifactId>
<version>3.7.0</version>
</dependency>
<dependency>
<groupId>org.ow2.orchestra.eclipse.birt</groupId>
<artifactId>org.ow2.orchestra.eclipse.birt.report.engine</artifactId>
<version>3.7.0</version>
</dependency>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>com.mchange</groupId>
<artifactId>mchange-commons-java</artifactId>
<version>0.2.9</version>
</dependency>
<dependency>
<groupId>org.jasypt</groupId>
<artifactId>jasypt</artifactId>
<version>1.5</version>
</dependency>
<dependency>
<groupId>httpunit</groupId>
<artifactId>httpunit</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>net.sf.jazzy</groupId>
<artifactId>jazzy</artifactId>
<version>0.5.2-rtext-1.4.1</version>
</dependency>
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>
<dependency>
<groupId>rome</groupId>
<artifactId>rome</artifactId>
<version>0.9</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.5.1</version>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.7.2</version>
</dependency>
<dependency>
<groupId>net.lingala.zip4j</groupId>
<artifactId>zip4j</artifactId>
<version>1.3.2</version>
</dependency>
<!-- DATABASE AND ORM-->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.199</version>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>3.4.5</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-ehcache</artifactId>
<version>5.3.12.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search-orm</artifactId>
<version>5.10.7.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.0.20.Final</version>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.jasypt</groupId>
<artifactId>jasypt-hibernate4</artifactId>
<version>1.9.3</version>
</dependency>
<!-- SPRING -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>5.3.13</version>
</dependency>
<!-- RETS -->
<!--DATA STRUCTURE -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
</dependency>
<!-- TESTS -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.7.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.7.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<version>${hamcrest.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>${hamcrest-all.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<defaultGoal>package</defaultGoal>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>${java.version}</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,91 @@
package com.crd;
import java.util.Properties;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.GnuParser;
import org.apache.commons.cli.Options;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Main {
private static final Logger logger = LoggerFactory.getLogger(Main.class);
private static Options options = new Options();
private static Properties properties = new Properties();
private static CommandLine cl = null;
private static boolean dryRun = false;
private static int limit = 0;
private static boolean force = false;
public static void main(String[] args) {
// get the idx feed properties file
Main.parseProperties();
// load console options
Main.parseCommandLine(args);
logger.debug("Starting feeds...");
System.out.println("starting feeds...");
// execute the feeds
Main.executeFeeds();
}
/**
* Executes the feeds specified in the feeds.properties file.
*/
private static void executeFeeds() {
}
/**
* Parses the properties file to get a list of all feeds.
*/
private static void parseProperties() {
try {
// load the properties file
logger.debug("Parsing properties");
Main.properties.load(Main.class.getClassLoader().getResourceAsStream("rets.properties"));
// load the feeds
} catch (Exception ex) {
ex.printStackTrace();
logger.error("Could not parse feed properties", ex);
}
}
/**
* Handles creation of console options.
*/
private static void parseCommandLine(String[] args) {
// parse command line options
CommandLineParser parser = new GnuParser();
try {
Main.cl = parser.parse(Main.options, args);
// get the dry run option
Main.dryRun = Main.cl.hasOption("d");
logger.trace("Value of dryRun: " + dryRun);
// get the limit option
// Main.limit = Utility.parseInt(Main.cl.getOptionValue("l", "0"));
logger.trace("Value of limit: " + Main.limit);
// get the force option
Main.force = Main.cl.hasOption("u");
logger.trace("Value of force: " + Main.force);
} catch (Exception ex) {
logger.error("An error ocurred parsing command line arguments", ex);
}
}
}

View File

@ -0,0 +1,63 @@
package com.crd.entity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.Serializable;
/**
* Heatmap Data object
*
* @author YuCheng
*/
public class HeatMapData implements Serializable {
private static final long serialVersionUID = 5530454436970805656L;
private static Logger logger = LoggerFactory.getLogger(HeatMapData.class);
private String timestamp;
private String AlertId;
private String Severity;
private String accurateValue;
public String getTimestamp() {
return timestamp;
}
public void setTimestamp(String timestamp) {
this.timestamp = timestamp;
}
public String getAlertId() {
return AlertId;
}
public void setAlertId(String alertId) {
AlertId = alertId;
}
public String getSeverity() {
return Severity;
}
public void setSeverity(String severity) {
Severity = severity;
}
public String getAccurateValue() {
return accurateValue;
}
public void setAccurateValue(String accurateValue) {
this.accurateValue = accurateValue;
}
/**
* Constructor
*/
public HeatMapData() {
}
}

View File

@ -0,0 +1,16 @@
package com.crd.overview;
/**
* Java Tutorial
*
* This is my first java program. This will print 'Hello World' as the output This is an example of multi-line comments
*
* @author YuCheng
*
*/
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World");
}
}

View File

@ -0,0 +1,56 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CORS TESTING</title>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>
<body>
<div class="container">
<h1>CORS TESTING</h1>
<!-- Content here -->
<p class="text-left">Update to your target API address:</p>
<input type="text" style="width:600px;height:30px;font-size:14px;" id="urlText" value="http://localhost:8080/search/user"/>
<p>&nbsp;
<p/>
<p class="text-left">Update to your Bearer Token:</p>
<input type="text" style="width:600px;height:30px;font-size:14px;" id="tokenTxt" value=""/>
<p>&nbsp;
<p/>
<input type="button" class="btn btn-outline-primary" id="cors" value="CHECK CORS"/>
</div>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<script type="text/javascript">
$("#cors").on('click', function (event) {
event.preventDefault();
var url2 = $("#urlText").val();
$.get({
contentType: 'application/x-www-form-urlencoded;charset=UTF-8',
url: url2,
beforeSend: function (xhr) {
if ($("#tokenTxt").val().trim()) {
/* Authorization header */
xhr.setRequestHeader("Authorization", "Bearer " + $("#tokenTxt").val());
}
},
success: function (data) {
alert("success");
}
})
});
</script>
</body>
</html>

View File

@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE RelativeLayout>
<Configuration status="WARN">
<Properties>
<Property name="baseDir">/home/logs/reoc/services/</Property>
</Properties>
<Appenders>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<!-- C O N S O L E - A P P E N D E R -->
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<Console name="CONSOLE" target="SYSTEM_OUT">
<PatternLayout pattern="%-d{yyyy/MM/dd HH:mm:ss} %-5p [%c] - %m%n"/>
<ThresholdFilter level="TRACE" onMatch="ACCEPT" onMismatch="DENY"/>
</Console>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<!-- D E B U G _ F I L E - A P P E N D E R -->
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<RollingFile name="FILE_DEBUG" append="true" fileName="${baseDir}/services_debug.log"
filePattern="${baseDir}/$${date:yyyy-MM}/services-debug-%d{yyyy-MM-dd}-%i.log.gz">
<ThresholdFilter level="DEBUG" onMatch="ACCEPT" onMismatch="DENY"/>
<PatternLayout>
<pattern>%-d{yyyy/MM/dd HH:mm:ss} %-5p [%c] - %m%n</pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy/>
<SizeBasedTriggeringPolicy size="250 MB"></SizeBasedTriggeringPolicy>
</Policies>
<DefaultRolloverStrategy max="12"/>
</RollingFile>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<!-- I N F O _ F I L E - A P P E N D E R -->
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<RollingFile name="FILE_INFO" append="true" fileName="${baseDir}/services_info.log"
filePattern="${baseDir}/$${date:yyyy-MM}/services-info-%d{yyyy-MM-dd}.log.gz">
<ThresholdFilter level="INFO" onMatch="ACCEPT" onMismatch="DENY"/>
<PatternLayout>
<pattern>%-d{yyyy/MM/dd HH:mm:ss} %-5p [%c] - %m%n</pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy/>
<SizeBasedTriggeringPolicy size="250 MB"></SizeBasedTriggeringPolicy>
</Policies>
<DefaultRolloverStrategy max="12"/>
</RollingFile>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<!-- F I L E _ W A R N - A P P E N D E R -->
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<RollingFile name="FILE_WARN" append="true" fileName="${baseDir}/services_info.log"
filePattern="${baseDir}/$${date:yyyy-MM}/services-warn-%d{yyyy-MM-dd}.log.gz">
<ThresholdFilter level="WARN" onMatch="ACCEPT" onMismatch="DENY"/>
<PatternLayout>
<pattern>%-d{yyyy/MM/dd HH:mm:ss} %-5p [%c] - %m%n</pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy/>
<SizeBasedTriggeringPolicy size="250 MB"></SizeBasedTriggeringPolicy>
</Policies>
<DefaultRolloverStrategy max="12"/>
</RollingFile>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<!-- F I L E _ E R R O R - A P P E N D E R -->
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<RollingFile name="FILE_ERROR" append="true" fileName="${baseDir}/services_error.log"
filePattern="${baseDir}/$${date:yyyy-MM}/services-error-%d{yyyy-MM-dd}.log.gz">
<ThresholdFilter level="ERROR" onMatch="ACCEPT" onMismatch="DENY"/>
<PatternLayout>
<pattern>%-d{yyyy/MM/dd HH:mm:ss} %-5p [%c] - %m%n</pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy/>
<SizeBasedTriggeringPolicy size="250 MB"></SizeBasedTriggeringPolicy>
</Policies>
<DefaultRolloverStrategy max="12"/>
</RollingFile>
</Appenders>
<!-- LOGGERS -->
<Loggers>
<Logger name="com" level="TRACE" additivity="false">
<AppenderRef ref="CONSOLE" level="DEBUG"/>
<AppenderRef ref="FILE_DEBUG" level="DEBUG"/>
<AppenderRef ref="FILE_INFO" level="INFO"/>
<AppenderRef ref="FILE_WARN" level="WARN"/>
<AppenderRef ref="FILE_ERROR" level="ERROR"/>
</Logger>
<root level="TRACE">
</root>
</Loggers>
</Configuration>

View File

@ -0,0 +1,6 @@
Jill,Doe
Joe,Doe
Justin,Doe
Jane,Doe
John,Doe
YuCheng,HU
1 Jill Doe
2 Joe Doe
3 Justin Doe
4 Jane Doe
5 John Doe
6 YuCheng HU

View File

@ -0,0 +1,7 @@
DROP TABLE people IF EXISTS;
CREATE TABLE people (
person_id BIGINT IDENTITY NOT NULL PRIMARY KEY,
first_name VARCHAR(20),
last_name VARCHAR(20)
);

View File

@ -0,0 +1,27 @@
package com.crd.tests;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
* @author YuCheng
*/
public class VariableTest {
private final static Logger logger = LoggerFactory.getLogger(VariableTest.class);
/**
* Do RetsServerConnection Test
*/
@Test
public void testStaticVariableChange() {
}
}

View File

@ -0,0 +1,97 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE RelativeLayout>
<Configuration status="WARN">
<Properties>
<Property name="baseDir">/home/logs/reoc/services/</Property>
</Properties>
<Appenders>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<!-- C O N S O L E - A P P E N D E R -->
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<Console name="CONSOLE" target="SYSTEM_OUT">
<PatternLayout pattern="%-d{yyyy/MM/dd HH:mm:ss} %-5p [%c] - %m%n" />
<ThresholdFilter level="TRACE" onMatch="ACCEPT" onMismatch="DENY" />
</Console>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<!-- D E B U G _ F I L E - A P P E N D E R -->
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<RollingFile name="FILE_DEBUG" append="true" fileName="${baseDir}/services_debug.log" filePattern="${baseDir}/$${date:yyyy-MM}/services-debug-%d{yyyy-MM-dd}-%i.log.gz">
<ThresholdFilter level="DEBUG" onMatch="ACCEPT" onMismatch="DENY" />
<PatternLayout>
<pattern>%-d{yyyy/MM/dd HH:mm:ss} %-5p [%c] - %m%n</pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy />
<SizeBasedTriggeringPolicy size="250 MB"></SizeBasedTriggeringPolicy>
</Policies>
<DefaultRolloverStrategy max="12" />
</RollingFile>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<!-- I N F O _ F I L E - A P P E N D E R -->
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<RollingFile name="FILE_INFO" append="true" fileName="${baseDir}/services_info.log" filePattern="${baseDir}/$${date:yyyy-MM}/services-info-%d{yyyy-MM-dd}.log.gz">
<ThresholdFilter level="INFO" onMatch="ACCEPT" onMismatch="DENY" />
<PatternLayout>
<pattern>%-d{yyyy/MM/dd HH:mm:ss} %-5p [%c] - %m%n</pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy />
<SizeBasedTriggeringPolicy size="250 MB"></SizeBasedTriggeringPolicy>
</Policies>
<DefaultRolloverStrategy max="12" />
</RollingFile>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<!-- F I L E _ W A R N - A P P E N D E R -->
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<RollingFile name="FILE_WARN" append="true" fileName="${baseDir}/services_info.log" filePattern="${baseDir}/$${date:yyyy-MM}/services-warn-%d{yyyy-MM-dd}.log.gz">
<ThresholdFilter level="WARN" onMatch="ACCEPT" onMismatch="DENY" />
<PatternLayout>
<pattern>%-d{yyyy/MM/dd HH:mm:ss} %-5p [%c] - %m%n</pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy />
<SizeBasedTriggeringPolicy size="250 MB"></SizeBasedTriggeringPolicy>
</Policies>
<DefaultRolloverStrategy max="12" />
</RollingFile>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<!-- F I L E _ E R R O R - A P P E N D E R -->
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<RollingFile name="FILE_ERROR" append="true" fileName="${baseDir}/services_error.log" filePattern="${baseDir}/$${date:yyyy-MM}/services-error-%d{yyyy-MM-dd}.log.gz">
<ThresholdFilter level="ERROR" onMatch="ACCEPT" onMismatch="DENY" />
<PatternLayout>
<pattern>%-d{yyyy/MM/dd HH:mm:ss} %-5p [%c] - %m%n</pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy />
<SizeBasedTriggeringPolicy size="250 MB"></SizeBasedTriggeringPolicy>
</Policies>
<DefaultRolloverStrategy max="12" />
</RollingFile>
</Appenders>
<!-- LOGGERS -->
<Loggers>
<Logger name="com" level="TRACE" additivity="false">
<AppenderRef ref="CONSOLE" level="DEBUG" />
<AppenderRef ref="FILE_DEBUG" level="DEBUG" />
<AppenderRef ref="FILE_INFO" level="INFO" />
<AppenderRef ref="FILE_WARN" level="WARN" />
<AppenderRef ref="FILE_ERROR" level="ERROR" />
</Logger>
<root level="TRACE">
</root>
</Loggers>
</Configuration>

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" ?>
<configuration debug="true">
<appender name="STDOUT"
class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned by default the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder -->
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>
%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n
</Pattern>
</layout>
</appender>
<root level="debug">
<appender-ref ref="STDOUT"/>
</root>
</configuration>