Commit 3c16fbdd authored by o2null's avatar o2null 💬

init

parent fcd14ef7
# Default ignored files
/workspace.xml
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
.mvn/wrapper/maven-wrapper.jar
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
.idea/**/encodings.xml
.idea/encodings.xml
# 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/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
.idea
# 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
*.iml
# eclipse
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.recommenders
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# PyDev specific (Python IDE for Eclipse)
*.pydevproject
# CDT-specific (C/C++ Development Tooling)
.cproject
# CDT- autotools
.autotools
# Java annotation processor (APT)
.factorypath
# PDT-specific (PHP Development Tools)
.buildpath
# sbteclipse plugin
.target
# Tern plugin
.tern-project
# TeXlipse plugin
.texlipse
# STS (Spring Tool Suite)
.springBeans
# Code Recommenders
.recommenders/
# Annotation Processing
.apt_generated/
.apt_generated_test/
# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet
# Uncomment this line if you wish to ignore the project description file.
# Typically, this file would be tracked if it contains build/dependency configurations:
.project
.classpath
.log
# vscode
.vscode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
**/pmd.xml
**/cpd.xml
**/pmd.html
**/cpd.html
# custom
app/**/*.iml
app/**/.project
app/**/.settings/
app/**/.classpath
app/*.iml
app/.project
app/**/*.log
app/log/dsdh/*.log
*/src/main/webapp/describe/
assembly/.settings
assembly/.project
assembly/*.iml
# o2custom-webarchive
# o2custom-archive
<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>
<parent>
<groupId>o2oa</groupId>
<artifactId>o2server</artifactId>
<version>6.1</version>
</parent>
<artifactId>o2custom-webarchive</artifactId>
<packaging>pom</packaging>
<modules>
<module>x_custom_webarchive_core_entity</module>
<module>x_custom_webarchive_assemble_control</module>
</modules>
<dependencies>
<dependency>
<groupId>o2oa</groupId>
<artifactId>x_base_core_project</artifactId>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<filesets>
<fileset>
<directory>${basedir}</directory>
<includes>
<include>**/*_.java</include>
</includes>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.3</version>
<configuration>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
<packagingExcludes>persistence.xml,WEB-INF/lib/**,META-INF
</packagingExcludes>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
<excludes>
<exclude>META-INF/**</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<linkXRef>true</linkXRef>
<sourceEncoding>utf-8</sourceEncoding>
<minimumTokens>100</minimumTokens>
<targetJdk>1.8</targetJdk>
<failOnViolation>false</failOnViolation>
<outputDirectory>${basedir}</outputDirectory>
</configuration>
<executions>
<execution>
<id>pmd-check</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.3</version>
</plugin>
</plugins>
</build>
</project>
<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>o2oa</groupId>
<artifactId>o2custom-webarchive</artifactId>
<version>6.1</version>
</parent>
<artifactId>x_custom_webarchive_assemble_control</artifactId>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>o2oa</groupId>
<artifactId>x_custom_webarchive_core_entity</artifactId>
<version>6.1</version>
</dependency>
<dependency>
<groupId>o2oa</groupId>
<artifactId>x_organization_core_entity</artifactId>
</dependency>
<dependency>
<groupId>o2oa</groupId>
<artifactId>x_organization_core_express</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>describeBuilder</id>
<phase>prepare-package</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<addOutputToClasspath>true</addOutputToClasspath>
<includePluginDependencies>true</includePluginDependencies>
<includeProjectDependencies>true</includeProjectDependencies>
<mainClass>com.x.base.core.project.annotation.DescribeBuilder</mainClass>
<arguments>
<argument>${basedir}</argument>
<argument>${project.build.sourceDirectory}</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>apiBuilder</id>
<phase>prepare-package</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<addOutputToClasspath>true</addOutputToClasspath>
<includePluginDependencies>true</includePluginDependencies>
<includeProjectDependencies>true</includeProjectDependencies>
<mainClass>com.x.base.core.project.annotation.ApiBuilder</mainClass>
<arguments>
<argument>${basedir}</argument>
<argument>${project.build.sourceDirectory}</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>checkAssemble</id>
<phase>prepare-package</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<addOutputToClasspath>true</addOutputToClasspath>
<includePluginDependencies>true</includePluginDependencies>
<includeProjectDependencies>true</includeProjectDependencies>
<mainClass>com.x.base.core.project.build.CheckAssemble
</mainClass>
</configuration>
</execution>
<execution>
<id>createWebXml</id>
<phase>prepare-package</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<addOutputToClasspath>true</addOutputToClasspath>
<includePluginDependencies>true</includePluginDependencies>
<includeProjectDependencies>true</includeProjectDependencies>
<mainClass>com.x.base.core.project.build.CreateWebXml</mainClass>
<arguments>
<argument>${basedir}</argument>
<argument>${project.artifactId}</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-war</id>
<phase>verify</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>../../o2oa/o2server/custom</outputDirectory>
<resources>
<resource>
<directory>target</directory>
<includes>
<include>${project.artifactId}.war</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
package com.x.custom.webarchive.assemble.control;
import com.x.base.core.container.EntityManagerContainer;
public abstract class AbstractFactory {
private Business business;
public AbstractFactory(Business business) throws Exception {
try {
if (null == business) {
throw new Exception("business can not be null.");
}
this.business = business;
} catch (Exception e) {
throw new Exception("can not instantiating factory.");
}
}
public EntityManagerContainer entityManagerContainer() throws Exception {
return this.business.entityManagerContainer();
}
public Business business() throws Exception {
return this.business;
}
}
package com.x.custom.webarchive.assemble.control;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
import com.x.base.core.project.Context;
@WebListener
public class ApplicationServletContextListener implements ServletContextListener {
@Override
public void contextInitialized(ServletContextEvent servletContextEvent) {
try {
ThisApplication.context = Context.concrete(servletContextEvent);
ThisApplication.init();
ThisApplication.context().regist();
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void contextDestroyed(ServletContextEvent servletContextEvent) {
try {
ThisApplication.destroy();
ThisApplication.context.destrory(servletContextEvent);
} catch (Exception e) {
e.printStackTrace();
}
}
}
\ No newline at end of file
package com.x.custom.webarchive.assemble.control;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.BaseTools;
import com.x.custom.webarchive.assemble.control.factory.SectionFactory;
import com.x.organization.core.express.Organization;
public class Business {
private static Logger logger = LoggerFactory.getLogger(Business.class);
// 自定义应用配置文件名称,根据实际配置修改,文件要求为json格式
private static final String PATH_CONFIG_CUSTOM = "config/o2custom_webarchive.json";
public static final String SECTION_SAMPLE_ID = "ce323f0e-894e-4958-b772-dfe9a88af5d3";
private EntityManagerContainer emc;
public Business(EntityManagerContainer emc) throws Exception {
this.emc = emc;
}
public EntityManagerContainer entityManagerContainer() {
return this.emc;
}
private static O2CustomWebArchive config = null;
// 读取自定义应用配置
public static synchronized O2CustomWebArchive config() {
try {
if (null == config) {
O2CustomWebArchive obj = BaseTools.readConfigObject(PATH_CONFIG_CUSTOM, O2CustomWebArchive.class);
if (null == obj) {
obj = O2CustomWebArchive.defaultInstance();
}
config = obj;
}
} catch (Exception e) {
logger.error(e);
}
return config;
}
// 组织架构管理相关的工厂服务类
private Organization organization;
// 示例数据表工厂服务类
private SectionFactory sampleEntityClassNameFactory;
public SectionFactory sampleEntityClassNameFactory() throws Exception {
if (null == this.sampleEntityClassNameFactory) {
this.sampleEntityClassNameFactory = new SectionFactory(this);
}
return sampleEntityClassNameFactory;
}
public Organization organization() throws Exception {
if (null == this.organization) {
this.organization = new Organization(ThisApplication.context());
}
return organization;
}
public static String defaultCatalogScript() {
StringBuilder sb = new StringBuilder();
sb.append("var html = '<table>';").append(StringUtils.LF);
sb.append("for (var i = 0; i < items.length; i++) {").append(StringUtils.LF);
sb.append("html += '<tr>';").append(StringUtils.LF);
sb.append("var item = items[i];").append(StringUtils.LF);
sb.append("if (item.getStatus() == 'success') {").append(StringUtils.LF);
sb.append("html += '<td>' + item.getTitle() + '</td>';").append(StringUtils.LF);
sb.append("html += '<td><a href=\"' + item.getUrl() + '\" target=\"_blank\">url</a></td>';")
.append(StringUtils.LF);
sb.append(
"html += '<td><a href=\"../../content/item/' + item.getId() + '/html\" target=\"_blank\">html</a></td>';")
.append(StringUtils.LF);
sb.append("html += '<td><a href=\"../../content/item/' + item.getId() + '/pdf\" target=\"_blank\">pdf</a></td>';")
.append(StringUtils.LF);
sb.append("html += '<td><a href=\"../../content/item/' + item.getId() + '/jpg\" target=\"_blank\">jpg</a></td>';")
.append(StringUtils.LF);
sb.append("} else if (item.getStatus() == 'failure') {").append(StringUtils.LF);
sb.append("html += '<td>' + item.getUrl() + '</td>';").append(StringUtils.LF);
sb.append(
"html += '<td clospan=4><a href=\"../../content/item/' + item.getId() + '/html\" target=\"_blank\">message</a></td>';")
.append(StringUtils.LF);
sb.append("} else {").append(StringUtils.LF);
sb.append("html += '<td clospan=5>' + item.getUrl() + '</td>';").append(StringUtils.LF);
sb.append("}").append(StringUtils.LF);
sb.append("html += '</tr>';").append(StringUtils.LF);
sb.append("}").append(StringUtils.LF);
sb.append("html += '</table>';").append(StringUtils.LF);
sb.append("return html;").append(StringUtils.LF);
return sb.toString();
}
}
package com.x.custom.webarchive.assemble.control;
import javax.activation.MimetypesFileTypeMap;
public class MimeTypeDefinition {
public static MimetypesFileTypeMap instance;
}
package com.x.custom.webarchive.assemble.control;
import org.apache.commons.lang3.StringUtils;
import org.quartz.CronExpression;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.config.ConfigObject;
import com.x.base.core.project.tools.NumberTools;
public class O2CustomWebArchive extends ConfigObject {
private static final long serialVersionUID = 4155132945577732193L;
public static final Integer DEFAULT_THREADPOOLSIZE = 3;
public static final String DEFAULT_CRON = "10 10 1,2,3,4,5,6,20,21,22,23 * * ?";
@FieldDescribe("catalog/list脚本")
private String catalogListScript = defaultCatalogListScript();
@FieldDescribe("执行线程数量,默认3个.")
private Integer threadPoolSize = DEFAULT_THREADPOOLSIZE;
@FieldDescribe("定时cron表达式")
private String cron = DEFAULT_CRON;
public String getCron() {
if (StringUtils.isNotEmpty(this.cron) && CronExpression.isValidExpression(this.cron)) {
return this.cron;
} else {
return DEFAULT_CRON;
}
}
public Integer getThreadPoolSize() {
return NumberTools.nullOrLessThan(threadPoolSize, 1) ? DEFAULT_THREADPOOLSIZE : threadPoolSize;
}
public String getCatalogListScript() {
return StringUtils.isEmpty(catalogListScript) ? defaultCatalogListScript() : catalogListScript;
}
private String defaultCatalogListScript() {
StringBuilder sb = new StringBuilder();
sb.append("var html = '';").append(StringUtils.LF);
sb.append("html += '<table>';").append(StringUtils.LF);
sb.append(
"html += '<tr><th>name</th><th>total</th><th>success</th><th>failure</th><th>wait</th><th>description</th></tr>';")
.append(StringUtils.LF);
sb.append("for (var i = 0; i < sections.length; i++) {").append(StringUtils.LF);
sb.append("var section = sections[i];").append(StringUtils.LF);
sb.append("html += '<tr>';").append(StringUtils.LF);
sb.append(
"html += '<td><a href=\"../catalog/section/' + section.getId() + '\" target=\"_blank\">' + section.getName() + '</a></td>';")
.append(StringUtils.LF);
sb.append("html += '<td>' + section.getTotal() + '</td>';").append(StringUtils.LF);
sb.append("html += '<td>' + section.getSuccess() + '</td>';").append(StringUtils.LF);
sb.append("html += '<td>' + section.getFailure() + '</td>';").append(StringUtils.LF);
sb.append("html += '<td>' + section.getWait() + '</td>';").append(StringUtils.LF);
sb.append("html += '<td>' + section.getProperties().getDescription() + '</td>';").append(StringUtils.LF);
sb.append("html += '</tr>';").append(StringUtils.LF);
sb.append("}").append(StringUtils.LF);
sb.append("html += '</table>';").append(StringUtils.LF);
sb.append("return html;").append(StringUtils.LF);
return sb.toString();
}
public static O2CustomWebArchive defaultInstance() {
O2CustomWebArchive o = new O2CustomWebArchive();
return o;
}