Merge pull request #10 from cwiki-us-docs/code_bank

Code bank PR to change version and adjust POM
This commit is contained in:
YuCheng Hu 2021-04-21 12:19:44 -04:00 committed by GitHub
commit 023662aa70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 387 additions and 273 deletions

View File

@ -1,16 +1,8 @@
<?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="cwiki-us-demo-tutorials" />
</profile>
</annotationProcessing>
<bytecodeTargetLevel target="1.8">
<module name="cwiki-us-demo-tutorials" target="1.8" />
<module name="cwiki-us-demo-tutorials" target="11" />
<module name="cwiki-us-demo-tutorials.spring-batch" target="11" />
<module name="cwiki-us-demo-tutorials.spring-batch.main" target="11" />
<module name="cwiki-us-demo-tutorials.spring-batch.test" target="11" />

View File

@ -4,38 +4,9 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="bc4dcfec-3698-4fde-a6cf-dd08b73f1f06" name="Default Changelist" comment="Discourse">
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/compiler.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/compiler.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/jarRepositories.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/jarRepositories.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/libraries/Maven__ch_qos_logback_logback_classic_1_1_7.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/libraries/Maven__ch_qos_logback_logback_core_1_1_7.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/libraries/Maven__commons_cli_commons_cli_1_2.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/libraries/Maven__net_bytebuddy_byte_buddy_1_8_15.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/libraries/Maven__net_bytebuddy_byte_buddy_agent_1_8_15.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/libraries/Maven__org_apache_commons_commons_lang3_3_11.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/libraries/Maven__org_apache_commons_commons_math3_3_6_1.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/libraries/Maven__org_apache_maven_surefire_surefire_logger_api_2_21_0.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/libraries/Maven__org_apiguardian_apiguardian_api_1_1_0.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/libraries/Maven__org_hamcrest_hamcrest_all_1_3.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/libraries/Maven__org_hamcrest_hamcrest_library_1_3.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_api_5_7_0.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_engine_5_7_0.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/libraries/Maven__org_junit_platform_junit_platform_commons_1_7_0.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/libraries/Maven__org_junit_platform_junit_platform_engine_1_7_0.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/libraries/Maven__org_mockito_mockito_core_2_21_0.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/libraries/Maven__org_objenesis_objenesis_2_6.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/libraries/Maven__org_opentest4j_opentest4j_1_2_0.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/libraries/Maven__org_slf4j_jcl_over_slf4j_1_7_21.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/libraries/Maven__org_slf4j_slf4j_api_1_7_21.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/modules.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" />
<list default="true" id="bc4dcfec-3698-4fde-a6cf-dd08b73f1f06" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/build.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/build.gradle" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lang-tutorial.iml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/settings.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/settings.gradle" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -81,10 +52,12 @@
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="aspect.path.notification.shown" value="true" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/toolkits/discourse" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/spring-batch" />
<property name="nodejs_package_manager_path" value="npm" />
</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="C:\WorkDir\GitHub\cwiki-us-docs\java-tutorials\spring-batch" />
<recent name="C:\WorkDir\GitHub\cwiki-us-docs\java-tutorials\toolkits\discourse" />
<recent name="C:\WorkDir\GitHub\cwiki-us-docs\java-tutorials\toolkits" />
<recent name="C:\WorkDir\GitHub\cwiki-us-docs\java-tutorials\toolkits\test\java\com\ossez\edtestbank\service\test" />
@ -120,7 +93,7 @@
<workItem from="1618145805266" duration="1634000" />
<workItem from="1618147512704" duration="6933000" />
<workItem from="1618246818887" duration="17236000" />
<workItem from="1618429441584" duration="2303000" />
<workItem from="1618429441584" duration="12732000" />
</task>
<task id="LOCAL-00001" summary="更新 POM 文件">
<created>1618147556538</created>
@ -150,7 +123,70 @@
<option name="project" value="LOCAL" />
<updated>1618157753954</updated>
</task>
<option name="localTasksCounter" value="5" />
<task id="LOCAL-00005" summary="添加忽略文件的内容">
<created>1618499169408</created>
<option name="number" value="00005" />
<option name="presentableId" value="LOCAL-00005" />
<option name="project" value="LOCAL" />
<updated>1618499169408</updated>
</task>
<task id="LOCAL-00006" summary="完成所有的文件的提交,以便于下一步的代码演示和开发">
<created>1618499203125</created>
<option name="number" value="00006" />
<option name="presentableId" value="LOCAL-00006" />
<option name="project" value="LOCAL" />
<updated>1618499203125</updated>
</task>
<task id="LOCAL-00007" summary="adjust the pom to make project can be compile">
<created>1618503350719</created>
<option name="number" value="00007" />
<option name="presentableId" value="LOCAL-00007" />
<option name="project" value="LOCAL" />
<updated>1618503350719</updated>
</task>
<task id="LOCAL-00008" summary="DiscourseImportTest move to different project">
<created>1618503445699</created>
<option name="number" value="00008" />
<option name="presentableId" value="LOCAL-00008" />
<option name="project" value="LOCAL" />
<updated>1618503445699</updated>
</task>
<task id="LOCAL-00009" summary="Change the compiler version to 3.7.0 version">
<created>1618509340144</created>
<option name="number" value="00009" />
<option name="presentableId" value="LOCAL-00009" />
<option name="project" value="LOCAL" />
<updated>1618509340144</updated>
</task>
<task id="LOCAL-00010" summary="提交 OSSRH 的提交地址">
<created>1618515214208</created>
<option name="number" value="00010" />
<option name="presentableId" value="LOCAL-00010" />
<option name="project" value="LOCAL" />
<updated>1618515214208</updated>
</task>
<task id="LOCAL-00011" summary="Add name and URL before push to OSSRH">
<created>1618519278569</created>
<option name="number" value="00011" />
<option name="presentableId" value="LOCAL-00011" />
<option name="project" value="LOCAL" />
<updated>1618519278569</updated>
</task>
<task id="LOCAL-00012" summary="Upgrade to using JDK 11">
<created>1618519439477</created>
<option name="number" value="00012" />
<option name="presentableId" value="LOCAL-00012" />
<option name="project" value="LOCAL" />
<updated>1618519439477</updated>
</task>
<task id="LOCAL-00013" summary="Change name and description">
<created>1618519836247</created>
<option name="number" value="00013" />
<option name="presentableId" value="LOCAL-00013" />
<option name="project" value="LOCAL" />
<updated>1618519836247</updated>
</task>
<option name="localTasksCounter" value="14" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@ -173,6 +209,15 @@
<MESSAGE value="Discourse Topic import" />
<MESSAGE value="项目的 POM 配置文件&#10;# Conflicts:&#10;#&#9;pom.xml" />
<MESSAGE value="Discourse" />
<option name="LAST_COMMIT_MESSAGE" value="Discourse" />
<MESSAGE value="添加忽略文件的内容" />
<MESSAGE value="完成所有的文件的提交,以便于下一步的代码演示和开发" />
<MESSAGE value="adjust the pom to make project can be compile" />
<MESSAGE value="DiscourseImportTest move to different project" />
<MESSAGE value="Change the compiler version to 3.7.0 version" />
<MESSAGE value="提交 OSSRH 的提交地址" />
<MESSAGE value="Add name and URL before push to OSSRH" />
<MESSAGE value="Upgrade to using JDK 11" />
<MESSAGE value="Change name and description" />
<option name="LAST_COMMIT_MESSAGE" value="Change name and description" />
</component>
</project>

View File

@ -13,7 +13,7 @@
<parent>
<groupId>com.ossez</groupId>
<artifactId>parent-modules</artifactId>
<version>1.0.0</version>
<version>0.0.1</version>
</parent>
<dependencyManagement>
@ -82,7 +82,7 @@
<rest-assured.version>3.3.0</rest-assured.version>
<!-- plugins -->
<thin.version>1.0.22.RELEASE</thin.version>
<spring-boot.version>2.4.0</spring-boot.version>
<spring-boot.version>2.4.5</spring-boot.version>
<aspectjweaver.version>1.9.1</aspectjweaver.version>
<!-- this property can be removed once we update Mockito version in the main pom.xml -->
<mockito.version>3.4.0</mockito.version>

View File

@ -10,8 +10,8 @@
<parent>
<groupId>com.ossez</groupId>
<artifactId>parent-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
<artifactId>java-tutorials</artifactId>
<version>0.0.1</version>
</parent>
<dependencies>
@ -26,11 +26,20 @@
<artifactId>commons-io</artifactId>
<version>${commons.io.version}</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
</dependency>
</dependencies>
<properties>
<guava.version>23.0</guava.version>
<commons.io.version>2.6</commons.io.version>
<!-- plugins -->
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
</properties>
</project>

128
pom.xml
View File

@ -2,24 +2,52 @@
<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.ossez</groupId>
<artifactId>lang-tutorial</artifactId>
<artifactId>parent-modules</artifactId>
<version>0.0.1</version>
<packaging>pom</packaging>
<name>CWIKIUS-OSSEZ Java Parent Modules</name>
<description>CWIKIUS-OSSEZ Java Tutorials For Algorithm And Learning</description>
<url>https://www.ossez.com/</url>
<scm>
<connection>https://github.com/cwiki-us-docs/java-tutorials.git</connection>
<url>https://github.com/cwiki-us-docs/java-tutorials.git</url>
</scm>
<developers>
<developer>
<name>YuCheng Hu</name>
<id>huyuchengus</id>
<email>huyuchengus@gmail.com</email>
<timezone>-5</timezone>
<organization>NORTH TECOM, LLC</organization>
<roles>
<role>Java Developer</role>
</roles>
</developer>
</developers>
<licenses>
<license>
<name>Apache 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>
<properties>
<!-- Generic properties -->
<java.version>1.8</java.version>
<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.12</slf4j.version>
<slf4j.version>1.7.30</slf4j.version>
<log4j2.version>2.2</log4j2.version>
<!-- Hibernate / JPA -->
<hibernate.version>4.3.5.Final</hibernate.version>
@ -209,7 +237,7 @@
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<version>3.7.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
@ -225,48 +253,68 @@
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<configuration>
<archive>
<manifest>
<mainClass>com.ossez.reoc.rets.Main</mainClass>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<phase>package</phase> <!-- bind to the packaging phase -->
<id>attach-sources</id>
<goals>
<goal>single</goal>
<goal>jar-no-fork</goal>
</goals>
<configuration>
<descriptor>src/assembly/zipAssembly.xml</descriptor>
<finalName>reoc-rets</finalName>
<archive>
<manifest>
<mainClass>com.ossez.reoc.rets.Main</mainClass>
</manifest>
<manifestEntries>
<Class-Path>./</Class-Path>
</manifestEntries>
</archive>
</configuration>
</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>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
</plugins>
</build>
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
</project>

View File

@ -24,5 +24,4 @@
<properties>
<start-class>com.baeldung.springamqp.simple.HelloWorldMessageApp</start-class>
</properties>
</project>

116
spring-batch/pom.xml Normal file
View File

@ -0,0 +1,116 @@
<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">
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-batch</artifactId>
<version>0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</build>
<name>spring-batch</name>
<packaging>jar</packaging>
<parent>
<artifactId>parent-boot-2</artifactId>
<groupId>com.ossez</groupId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../parent-boot-2</relativePath>
</parent>
<dependencies>
<!-- JAXB APIs & runtime no longer provided in JDK 11 -->
<!-- see http://openjdk.java.net/jeps/320 -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>${jaxb.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>${jaxb.version}</version>
<scope>runtime</scope>
</dependency>
<!-- SQLite database driver -->
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>${sqlite.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>${spring.version}</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-core</artifactId>
<version>${spring.batch.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-test</artifactId>
<version>${spring.batch.version}</version>
</dependency>
<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>${opencsv.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-batch</artifactId>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>${awaitility.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<spring.version>5.3.0</spring.version>
<spring.batch.version>4.3.0</spring.batch.version>
<sqlite.version>3.15.1</sqlite.version>
<opencsv.version>4.1</opencsv.version>
<jaxb.version>2.3.1</jaxb.version>
<awaitility.version>3.1.1</awaitility.version>
</properties>
</project>

View File

@ -1,12 +1,12 @@
package com.ossez.spring.batch;
import org.baeldung.batch.model.Transaction;
import org.baeldung.batch.service.CustomItemProcessor;
import org.baeldung.batch.service.CustomSkipPolicy;
import org.baeldung.batch.service.MissingUsernameException;
import org.baeldung.batch.service.NegativeAmountException;
import org.baeldung.batch.service.RecordFieldSetMapper;
import org.baeldung.batch.service.SkippingItemProcessor;
import com.ossez.spring.batch.model.Transaction;
import com.ossez.spring.batch.service.CustomItemProcessor;
import com.ossez.spring.batch.service.CustomSkipPolicy;
import com.ossez.spring.batch.service.MissingUsernameException;
import com.ossez.spring.batch.service.NegativeAmountException;
import com.ossez.spring.batch.service.RecordFieldSetMapper;
import com.ossez.spring.batch.service.SkippingItemProcessor;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;

View File

@ -1,8 +1,7 @@
package org.baeldung.batch.model;
import java.util.Date;
package com.ossez.spring.batch.model;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.Date;
@SuppressWarnings("restriction")
@XmlRootElement(name = "transactionRecord")

View File

@ -1,7 +1,7 @@
package com.ossez.spring.batch.partitioner;
import org.baeldung.batch.model.Transaction;
import org.baeldung.batch.service.RecordFieldSetMapper;
import com.ossez.spring.batch.model.Transaction;
import com.ossez.spring.batch.service.RecordFieldSetMapper;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;

View File

@ -3,7 +3,7 @@ package com.ossez.spring.batch.service;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import org.baeldung.batch.model.Transaction;
import com.ossez.spring.batch.model.Transaction;
import org.springframework.batch.item.file.mapping.FieldSetMapper;
import org.springframework.batch.item.file.transform.FieldSet;
import org.springframework.validation.BindException;

View File

@ -1,6 +1,6 @@
package com.ossez.spring.batch.service;
import org.baeldung.batch.model.Transaction;
import com.ossez.spring.batch.model.Transaction;
import org.springframework.batch.item.ItemProcessor;
public class SkippingItemProcessor implements ItemProcessor<Transaction, Transaction> {

View File

@ -2,37 +2,15 @@ package com.ossez.lang.tutorial.overview;
/**
* Java Tutorial
*
<<<<<<< HEAD
*
* This is my first java program. This will print 'Hello World' as the output This is an example of multi-line comments
*
=======
<<<<<<< HEAD
=======
* This is my first java program. This will print 'Hello World' as the output This is an example of multi-line comments
*
>>>>>>> 361e407d91e00158295aadeaca0a91d84a534820
>>>>>>> RB
*
* @author YuCheng
*
*/
public class HelloWorld {
public static void main(String[] args) {
<<<<<<< HEAD
=======
<<<<<<< HEAD
System.out.println("Hello World");
}
}
=======
>>>>>>> RB
// This is an example of single line comment
/* This is also an example of single line comment. */
System.out.println("Hello World");
}
}
<<<<<<< HEAD
=======
>>>>>>> 361e407d91e00158295aadeaca0a91d84a534820
>>>>>>> RB

View File

@ -1,137 +0,0 @@
package com.ossez.lang.tutorial.tests;
import com.google.gson.Gson;
import com.ossez.edtestbank.common.dao.Factory;
import com.ossez.edtestbank.common.dao.factories.PostFactory;
import com.ossez.edtestbank.common.model.entity.BBSOssezForumAttach;
import com.ossez.edtestbank.common.model.entity.BBSOssezForumPost;
import com.ossez.edtestbank.common.model.request.TopicRequest;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.apache.http.HttpHeaders;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.joda.time.DateTime;
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 java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* Test Logger and function
*
* @author YuCheng Hu
*/
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class PostTest {
private static Logger logger = LoggerFactory.getLogger(PostTest.class);
@BeforeAll
protected void setUp() throws Exception {
Factory.beginTransaction();
}
@AfterAll
protected void tearDown() throws Exception {
Factory.rollbackTransaction();
}
/**
* Tests search functionality for the customer object.
*/
@Test
public void testPost() throws IOException, InterruptedException {
List<String> idList = FileUtils.readLines(new File("C:\\Users\\yhu\\Pictures\\Pics\\2021-01\\1.txt"));
for (String id : idList) {
processPost(NumberUtils.toLong(id));
Thread.sleep(6000);
// break;
}
// make sure the customer was found
// assertNotNull(bbsOssezForumPost);
}
@Test
public void testDateTime() throws IOException {
DateTime dateTime = new DateTime(1256834117 * 1000L);
System.out.println(dateTime.toString());
}
private void processPost(Long tid) throws IOException {
BBSOssezForumPost bbsOssezForumPost = PostFactory.getBBSOssezForumPostTid(tid);
if (bbsOssezForumPost == null)
return;
logger.debug("Questions Content - {}", bbsOssezForumPost.getSubject());
String postCtx = bbsOssezForumPost.getMessage();
// logger.debug(">>>>{}", postCtx);
String pattern = "\\[attach\\]((\\d)*?)\\[\\/attach\\]";
// Create a Pattern object
Pattern r = Pattern.compile(pattern);
// Now create matcher object.
Matcher m = r.matcher(postCtx);
while (m.find()) {
String attachId = StringUtils.substringBetween(m.group(0), "[attach]", "[/attach]");
logger.debug("{}", attachId);
BBSOssezForumAttach bbsOssezForumAttach = PostFactory.getBBSOssezForumAttach(NumberUtils.toLong(attachId));
if (bbsOssezForumAttach!= null) {
String fullURL = "![](https://cdn.ossez.com/com-ossez-www/data/attachment/forum/" + bbsOssezForumAttach.getAttachment() + ")";
postCtx = StringUtils.replace(postCtx, m.group(0), fullURL);
}
}
logger.debug("{}", postCtx);
CloseableHttpClient client = HttpClients.createDefault();
HttpPost httpPost = new HttpPost("https://www.ossez.com/posts.json");
httpPost.setHeader(HttpHeaders.CONTENT_TYPE, "application/json; charset=UTF-8");
httpPost.setHeader("Api-Key", "XXXXXX");
httpPost.setHeader("Api-Username", "XXXXXX");
TopicRequest topicRequest = new TopicRequest();
topicRequest.setTitle(bbsOssezForumPost.getSubject());
topicRequest.setRaw(postCtx);
topicRequest.setCreated_at(new DateTime(bbsOssezForumPost.getDateline() * 1000L).toString() );
topicRequest.setCategory(30);
StringEntity postingString = new StringEntity(new Gson().toJson(topicRequest), StandardCharsets.UTF_8);
httpPost.setEntity(postingString);
CloseableHttpResponse response = client.execute(httpPost);
logger.info("{}", EntityUtils.toString(response.getEntity()), StandardCharsets.UTF_8);
client.close();
}
}

View File

@ -10,7 +10,7 @@
</profile>
</annotationProcessing>
<bytecodeTargetLevel>
<module name="discourse" target="11.0.10" />
<module name="discourse" target="1.8" />
<module name="toolkits" target="1.8" />
</bytecodeTargetLevel>
</component>

72
toolkits/codebank/pom.xml Normal file
View File

@ -0,0 +1,72 @@
<?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.ossez</groupId>
<artifactId>codebank</artifactId>
<version>0.0.1</version>
<name>codebank</name>
<packaging>jar</packaging>
<parent>
<groupId>com.ossez</groupId>
<artifactId>parent-java</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../../parent-java</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.11</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.10.10</version>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<version>2.2</version>
</dependency>
</dependencies>
<build>
<finalName>discourse</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<properties>
<!-- testing -->
<assertj.version>3.6.1</assertj.version>
<asspectj.version>1.8.9</asspectj.version>
<jmh-core.version>1.19</jmh-core.version>
<jmh-generator.version>1.19</jmh-generator.version>
</properties>
</project>

View File

@ -27,11 +27,6 @@
<version>4.5.13</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
@ -72,8 +67,6 @@
<asspectj.version>1.8.9</asspectj.version>
<jmh-core.version>1.19</jmh-core.version>
<jmh-generator.version>1.19</jmh-generator.version>
<!-- plugins -->
<maven-surefire-plugin.version>2.22.1</maven-surefire-plugin.version>
</properties>
</project>

View File

@ -112,8 +112,8 @@ public class DiscourseTopicsImportTest {
HttpPost httpPost = new HttpPost("https://www.ossez.com/posts.json");
httpPost.setHeader(HttpHeaders.CONTENT_TYPE, "application/json; charset=UTF-8");
httpPost.setHeader("Api-Key", "8d789c529c4c22bf1dac3de7dbe7b29af10f2429aeb9a1914eff6da70c2265a9");
httpPost.setHeader("Api-Username", "honeymoose");
httpPost.setHeader("Api-Key", "XXXX");
httpPost.setHeader("Api-Username", "XXXX");
TopicRequest topicRequest = new TopicRequest();
topicRequest.setTitle(bbsOssezForumPost.getSubject());